clang-omp / clang

clang with OpenMP 3.1 and some elements of OpenMP 4.0 support
clang-omp.github.com
Other
91 stars 15 forks source link

Compiling clang-omp against STL on OSX 10.9 #32

Closed taiya closed 10 years ago

taiya commented 10 years ago

For this simple STL helloworld:

#include <iostream>
#include <vector>
int main() {
    std::vector<int> vec;
    std::cout << vec.size() << std::endl;
    return 0;
}

Compiled "ok" with the default clang compiler:

/usr/bin/clang++ clang.cpp 

But if I compile it with the clang-omp I get this error:

/usr/local/bin/clang++ clang.cpp 
clang.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
         ^
1 error generated.

I know I am missing the STL library; but what's the proper way to proceed?

alexey-bataev commented 10 years ago

Hi, You just need to provide path to your STL library -isystem

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

taiya commented 10 years ago

Thanks Alexey for your reply. I backtracked in a IDE what "iostream" the XCode clang was using, and now this compiles correctly:

/usr/local/bin/clang++ -isystem /Library/Developer/CommandLineTools/usr/lib/c++/v1 clang.cpp

Nonetheless, I do not find this a completely satisfactory solution. This is exactly why in my original question I was asking for the proper way of configuring this. Why the /usr/bin/clang does not need the aforementioned -isystem? Is there a way of telling clang where to look for these by default? I also looked at the "clang -print-search-dirs" but these do not seem to be relevant.

Basically I want to obtain an identical configuration to the one that ships with the XCode compiler.

alexey-bataev commented 10 years ago

/usr/bin/clang is clang built by Apple and it is preconfigured by Apple to know path to libc++ library. Clang built from trunk does not know about path to libc++. Before Xcode 5 libc++ was placed in standard /usr/include and clang was able to locate it. But since Xcode 5 it was changed and clang built from sources requires additional options.

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

taiya commented 10 years ago

As I am compiling Clang myself is there a default way to pre-configure my custom clang build to know where to find the STL libraries? (I could even ship them with the compiler as apple does, except I'd place them in /usr/local/include)

alexey-bataev commented 10 years ago

You can call ayour clang with flag -v which shows standard paths where clang is trying to located some standard includes. You may place your libc++ in one of these directories. For example, clang tries to find include files in /usr/local/include, you can put them to this directory.

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

taiya commented 10 years ago

Perfect, that's exactly what I was looking for.