Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS X 10.8 and llvm/clang 3.3 via homebrew

I have latest version of XCode installed on my Mac OS X 10.8 with LLVM 3.2. Now I would like to switch to llvm/clang 3.3.

In my current project I use CMake with clang 3.2 and libc++ which are working fine.

Now I thought I could switch using homebrew. So what I did was issuing the following command:

brew install llvm --with-clang --with-asan

This built new clang and updated it in /usr/local/bin.

Running cmake with the following parameters:

cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/local/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/bin/clang++ ../

Succeeded and my CMake output looks like:


-- Compiler: Clang
-- CXX_FLAGS: -Wall -std=c++11 -stdlib=libc++
-- Boost version: 1.53.0
-- adding include directory: /usr/local/include
-- adding include directory: /usr/local/include
-- adding include directory: /usr/local/include
-- adding include directory: /usr/local/include
-- Boost version: 1.53.0
-- Found the following Boost libraries:
--   filesystem
--   system
--   exception
-- Boost version: 1.53.0
-- Found the following Boost libraries:
--   unit_test_framework
--   thread
-- Configuring done
-- Generating done

But if I start building my project I receive an error:


[  2%] Building CXX object code/CMakeFiles/.../resource.cpp.o
In file included from /Users/.../code/net/resource.cpp:1:
/Users/.../resource.hpp:6:10: fatal error: 'string' file not found
#include <string>
         ^
1 error generated.

So obviously standard header is not found, which with clang 3.2 was found. What can be causing this problem?

Remark: I think my problem is that brew builds llvm/clang with libstdc++ instead of libc++. Is there any way I can force it to use libc++? Or is there any other easy way to upgrade clang on OS X and use libc++?

like image 444
ovanes Avatar asked Nov 03 '22 19:11

ovanes


1 Answers

Add -stdlib=libc++ to the build parameters to configure clang to use libc++.

like image 120
Paul Fultz II Avatar answered Nov 09 '22 12:11

Paul Fultz II