Works great Jean-Daniel! Thanks a lot!

Regards,
Rob J. Goedman
[email protected]




On Nov 25, 2013, at 10:49 AM, Jean-Daniel Dupas <[email protected]> wrote:

> 
> On OS X Maverick, libc++ headers are part of the compiler toolchain and not 
> of the system. That's why when using a custom toolchain (or clang based 
> tool), you got this error.
> 
> To use libc++ with your own clang build, you have to install it alongside 
> your clang binary.
> 
> The good news is that it will be automatically done when installing clang if 
> you checkout the libc++ project at the right place, that is in <llvm 
> sources>/projects/libcxx
> 
> cd <llvm sources>/projects
> svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx
> 
> Now, go to your build directory and run make install again.
> 
> It should install the clang tools and libc++ headers at the right place, and 
> clang should find them.
> 
> Note that if you want to know where clang look for the libc++ headers, you 
> can pass the "-v" flags to the compiler to tell it to print the header search 
> path.
> 
> Le 25 nov. 2013 à 19:14, Robert J Goedman <[email protected]> a écrit :
> 
>> Hi,
>> 
>> After watching Chandler Carruth's 
>> http://channel9.msdn.com/Events/GoingNative/2013/The-Care-and-Feeding-of-C-s-Dragons
>>  I decided to try the format and modernize examples in the middle of his 
>> presentation. After installing the latest LLVM suite, all examples without 
>> #include files work fine, both in clang-format and clang-modernize. Very 
>> impressive.
>> 
>> Using the native (Apple, Xcode) toolchain, I can cmake, make and run the 
>> example programs in a build directory directly under the source directory, 
>> e,g. clang-tools/vector/build under clang-tools/vector which contains 
>> vector.cpp and CMakeLists.txt.
>> 
>> But clang-modernize will fail *if* it contains a template based #include, 
>> e.g. Chandler's loop-convert example based on a small vector<int> loop.
>> Somehow I can't figure out how to specify the right flags for the 
>> compiler/linker in cmakelist.txt.
>> 
>> Any pointers appreciated!
>> 
>> Thanks,
>> Rob J. Goedman
>> [email protected]
>> 
>> ------------/clang-tools/vector/vector.cpp------------
>> 
>> #include <vector>
>> #include <iostream>
>> 
>> int sum(const std::vector<int> &numbers) {
>>  int result = 0;
>>  for (std::vector<int>::const_iterator it = numbers.begin();
>>       it != numbers.end(); ++it) {
>>    result += *it;
>>  }
>>  return result;
>> }
>> 
>> int main() {
>>  std::vector<int> nums = { 1, 5, 6, 38 };
>>  std::cout << sum(nums) << std::endl;
>> }
>> 
>> -------------/clang-tools/vector/CMakeLists.Txt
>> 
>> project(foundations)
>> cmake_minimum_required(VERSION 2.8)
>> 
>> include_directories($ENV{GMOCK_HOME}/include $ENV{GMOCK_HOME}/gtest/include)
>> link_directories($ENV{GMOCK_HOME}/mybuild $ENV{GMOCK_HOME}/gtest/mybuild)
>> add_definitions(-stdlib=libc++ -std=c++11)
>> 
>> set(sources 
>>  vector.cpp
>> )
>> 
>> add_executable(test ${sources})
>> target_link_libraries(test pthread)
>> target_link_libraries(test gmock)
>> target_link_libraries(test gtest)
>> 
>> -----------------------
>> 
>> robs-15inch-2:build rob$ rm -rf *
>> robs-15inch-2:build rob$ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
>> -- The C compiler identification is Clang 5.0.0
>> -- The CXX compiler identification is Clang 5.0.0
>> -- Check for working C compiler: /usr/bin/cc
>> -- Check for working C compiler: /usr/bin/cc -- works
>> -- Detecting C compiler ABI info
>> -- Detecting C compiler ABI info - done
>> -- Check for working CXX compiler: /usr/bin/c++
>> -- Check for working CXX compiler: /usr/bin/c++ -- works
>> -- Detecting CXX compiler ABI info
>> -- Detecting CXX compiler ABI info - done
>> -- Configuring done
>> -- Generating done
>> -- Build files have been written to: 
>> /Users/rob/Projects/Languages/Cpp/clang_tools/vector/build
>> robs-15inch-2:build rob$ make
>> Scanning dependencies of target test
>> [100%] Building CXX object CMakeFiles/test.dir/vector.cpp.o
>> Linking CXX executable test
>> [100%] Built target test
>> robs-15inch-2:build rob$ ./test
>> 50
>> robs-15inch-2:build rob$ clang-format -style LLVM -i ../vector.cpp 
>> robs-15inch-2:build rob$ clang-modernize -summary -p . -include ..
>> Parse: /Users/rob/Projects/Languages/Cpp/clang_tools/vector
>> /Users/rob/Projects/Languages/Cpp/clang_tools/vector/vector.cpp:1:10: fatal 
>> error: 'vector' file not found
>> #include <vector>
>>         ^
>> 1 error generated.
>> Error while processing 
>> /Users/rob/Projects/Languages/Cpp/clang_tools/vector/vector.cpp.
>> Error encountered during translation.
>> 
>> _______________________________________________
>> cfe-users mailing list
>> [email protected]
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users
> 
> -- Jean-Daniel
> 
> 
> 
> 

_______________________________________________
cfe-users mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users

Reply via email to