question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

build failure with Xcode 10 - libstdc++ not supported anymore

See original GitHub issue

Code Sample, a copy-pastable example if possible

(pandas-dev) bilbo:pandas-rb robertbuckley$ python setup.py build_ext --inplace -j 4

running build_ext
building 'pandas._libs.window' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/robertbuckley/anaconda3/envs/pandas-dev/include -arch x86_64 -I/Users/robertbuckley/anaconda3/envs/pandas-dev/include -arch x86_64 -Ipandas/_libs -I./pandas/_libs -Ipandas/_libs/src/klib -Ipandas/_libs/src -I/Users/robertbuckley/anaconda3/envs/pandas-dev/lib/python3.6/site-packages/numpy/core/include -I/Users/robertbuckley/anaconda3/envs/pandas-dev/include/python3.6m -c pandas/_libs/window.cpp -o build/temp.macosx-10.7-x86_64-3.6/pandas/_libs/window.o -Wno-unused-function
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
pandas/_libs/window.cpp:655:10: fatal error: 'ios' file not found
#include "ios"
         ^~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1

Problem description

I setup a dev environment on Mac OS 10.13 according to https://pandas.pydata.org/pandas-docs/stable/contributing.html#creating-a-development-environment and all was well

Upgraded to 10.14 (mojave) and Xcode 10, and now i get the above failure.

Xcode 10 release notes includes the following deprecation notice

Building with libstdc++ was deprecated with Xcode 8 and is not supported in Xcode 10 when targeting iOS. C++ projects must now migrate to libc++ and are recommended to set a deployment target of macOS 10.9 or later, or iOS 7 or later. Besides changing the C++ Standard Library build setting, developers should audit hard-coded linker flags and target dependencies to remove references to libstdc++ (including -lstdc++, -lstdc++.6.0.9, libstdc++.6.0.9.tbd, and libstdc++.6.0.9.dylib). Project dependencies such as static archives that were built against libstdc++ will also need to be rebuilt against libc++. (40885260)

Some workaround suggestions are at https://stackoverflow.com/questions/52425766/stdlibc-headers-not-found-error-on-xcode-10 and the answer its linked to.

I dont have access to Xcode 9 anymore, so i can’t try the workaround of copying the old libs from there

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:23 (22 by maintainers)

github_iconTop GitHub Comments

24reactions
robbuckleycommented, Jan 6, 2019

Hi, I got to the bottom of this issue, in the end, after a trawl through clang, distutils and python make/config files.

The compiler standard library defaults to either libstdc++ or libc++, depending on the targetted macOS version - libstdc++ for 10.8 and below, and libc++ for 10.9 and above. This is determined by the environment variable MACOSX_DEPLOYMENT_TARGET or the compiler option-mmacosx-version-min, defaulting to the system version otherwise.

When distuils builds extensions on macOS, it setsMACOSX_DEPLOYMENT_TARGET to the version that python was compiled with, even if the host system / Xcode is newer.

Recent macOS versions of python have a 64-bit only variant built for 10.9 (python.org), and a universal 64/32-bit variant built for 10.6 (python.org) or 10.7 (conda). I am running the conda universal variant, so distutils targets macOS 10.7, despite my system being 10.14, with Xcode 10 which doesn’t install libstdc++. Hence the failure I saw.

It may work for some users, for 1 of 2 reasons:

  • libstdc++ is lying around somewhere from a previous Xcode 9 install
  • when running a recent 64-bit only variant of python, which targets macOS 10.9 and hence libc++

I’ve pushed a revised change which sets the targeted macOS to 10.9, when running on a 10.9 or above system, with a python/distutils which targets pre-10.9. This should not break builds on pre-10.9 systems, unlike my previous approach. It fixes the issue on my system. CI is running now.

Please let me know if you’d like me to submit it as a PR (assuming CI passes)

6reactions
JustinZhengBCcommented, Nov 3, 2018

Not sure if it’s the same issue or if this is a good fix, but I also couldn’t build after updating to mojave (I got my error at a different point though). I fixed it by adding the argument extra_link_args=["-stdlib=libc++", "-mmacosx-version-min=10.9"] to the initialization of Extension object obj here.

https://github.com/pandas-dev/pandas/blob/d78bd7a65f87022bae5021d36c8656c0ea5a7b76/setup.py#L672-L680

Credit for idea here

Here’s my error log before performing the above step:

g++ -bundle -undefined dynamic_lookup -L/Users/admin/anaconda3/envs/pandas-dev/lib -arch x86_64 -L/Users/admin/anaconda3/envs/pandas-dev/lib -arch x86_64 -L/usr/local/opt/libarchive/lib -I/usr/local/opt/libarchive/include -arch x86_64 build/temp.macosx-10.7-x86_64-3.6/pandas/_libs/window.o -o /Users/admin/Documents/Projects/pandas-jz/pandas/_libs/window.cpython-36m-darwin.so
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'g++' failed with exit status 1
Read more comments on GitHub >

github_iconTop Results From Across the Web

Xcode 10 beta 4 - stdlibc++ header… | Apple Developer Forums
I get this warning compiling Tesseract OCR engine on beta 4. warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the...
Read more >
ld: library not found for -lstdc++.6 - Xcode 10 - Stack Overflow
It's like delivering an .app which isn't supported anymore on that OS version, you have to fix it and rebuilt it. Same here...
Read more >
Oh dear! Build errors? - LoopDocs - GitHub Pages
Solution: Go to your Xcode -> Preferences (or Settings) and under the Locations tab, select your Xcode version (the figure shows 14.0.1 -...
Read more >
[Resolve]-Xcode 10 (iOS 12) does not contain libstdc++6.0.9
Copy it from old Xcode(9.4) will work for physical iOS devices. For Simulator issues with Did find: /usr/lib/libstdc++.6.dylib: mach-o, but not built for ......
Read more >
Library not loaded: /usr/lib/libstdc++.6.dylib error in Xcode 10
We are having the same issue. Xcode 10 does not include the libstdc++.6.dylib library. It was actually deprecated a while back.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found