Jephron
Jephron

Reputation: 2758

OSX gcc not finding installed libs

I'm rediscovering the horror of compiling C. I just installed libtins from http://libtins.github.io, following the usual ./configure -> make -> sudo make install pattern.

sudo make install definitely put headers in /usr/local/include/tins but it doesn't seem like g++ is able to see them.

following the advice here, I tried running gcc -x c++ -v -E /dev/null in order to see the include paths.

clang -cc1 version 5.1 based upon LLVM 3.4svn default target x86_64-apple-darwin13.3.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks (framework directory)
End of search list.

I would have expected to see /usr/local/include in there somewhere. Are the default paths paths all inside the Xcode app now?

app.cpp

#include <tins/tins.h>

int main() {
    return 1;
}

compile command

g++ app.cpp -ltins

result

app.cpp:3:10: fatal error: 'tins/tins.h' file not found

Any idea how to make g++ see the headers?

Upvotes: 1

Views: 1240

Answers (1)

jrd1
jrd1

Reputation: 10726

You didn't set the include path when compiling. Hence, the correct compilation line should be:

g++ app.cpp -I/usr/local/include -L/usr/local/lib -ltins

Upvotes: 5

Related Questions