1

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?

Community
  • 1
  • 1
Jephron
  • 2,652
  • 1
  • 23
  • 34
  • I have since tried putting the `tins` folder into `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include`. g++ immediately picks it up. That shouldn't be necessary though, should it? – Jephron Aug 24 '14 at 02:24
  • It is *not* necessary. `/usr/local/include` and `/usr/local/lib` are *not* part of the default search paths for the preprocessor on OS X. The output you're showing is evidence of that. You can either (a) modify the default search path for the preprocessor (not recommended) or (b) modify the preprocessor search sources using `-Ipath` (and *likely* associated `-Llibpath` for the linker). `clang` *used to do this for you* (gcc did not) for `/usr/local/include`. However, mine *does* [see here](http://pastebin.com/vbc1LJH6) in gcc-mode (interesting). – WhozCraig Aug 24 '14 at 03:01

1 Answers1

5

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
jrd1
  • 10,358
  • 4
  • 34
  • 51