unrecognized command line option '-stdlib=libc++' gcc (Homebrew gcc 5.3.0) 5.3.0

17,850

Solution 1

As the error message says, the gcc compiler has no such commandline option as -stdlib. The LLVM clang compiler does. That is because clang offers you the choice of linking the LLVM standard C++ library (libc++) or the GNU standard C++ library (libstdc++), whereas gcc supports only libstdc++.

Delete the option -stdlib=libc++. You might as well also replace -std=c++0x with -std=c++11, since the former denotes experimental support for the 2011 C++11 standard, applicable for gcc versions 4.3 through 4.6.

Solution 2

It might also be useful to install the clang/clang++ compiler and use this when it comes to the build step (because you are likely to run into gcc issues with other Python packages):

python configure.py
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
python setup.py build
make -j 4
python setup.py install
cd ../
python -c "import pyopencl"
Share:
17,850
Maxim.K.
Author by

Maxim.K.

I'm a mathematician programming on #python.

Updated on June 04, 2022

Comments

  • Maxim.K.
    Maxim.K. almost 2 years

    I run Mac OSX El Capitan, I have installed via Homebrew gcc version 5.3.0.

    I want to install pyopencl (but as I understand it doesn't matter) and when running the following command:

    gcc -fno-strict-aliasing -fwrapv -Wall -O3 -DNDEBUG -DPYGPU_PACKAGE=pyopencl -DPYGPU_PYOPENCL=1 -Isrc/c_wrapper/ -I/Users/earendilllock/anaconda/include/python2.7 -c build/temp.macosx-10.5-x86_64-2.7/pyopencl._cffi.cpp -o build/temp.macosx-10.5-x86_64-2.7/build/temp.macosx-10.5-x86_64-2.7/pyopencl._cffi.o -std=c++0x -stdlib=libc++ -mmacosx-version-min=10.7 -arch i386 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk

    I have obtained the following error:

    gcc: error: unrecognized command line option '-stdlib=libc++'
    error: command 'gcc' failed with exit status 1
    make: *** [all] Error 1
    

    I could not find the solution for resolving that problem via Google, but I hope it exists.