开发者

Toolchain question: How do you add a header/lib so the compiler knows where to find it?

I have made a toolchain using this script: http://gist.github.com/403608 (more or less modified to get it to work)

Every开发者_Python百科thing is installed and now when I try to compile using it I get an error when I ./configure it says that my C compiler cannot create exeicutables. I'm thinking that my compiler just doesn't know where to look for all the headers and libs... cause they are not in /usr/ they are in /var/sdk/usr/

is there a way to tell my compiler to always look in /var/sdk/usr/ also?


Most configure scripts use LDFLAGS and CPPFLAGS environment variables to modify directory search paths for includes and libs.

LDFLAGS="-L/other/libs" CPPFLAGS="-I/other/includes" ./configure

You can also look at the compiler documentation as they usually have environment variables they look at as well. For example gcc looks in directories listed LIBRARY_PATH for libs. It will also look directories CPATH for includes.


Go into your target settings (control-click on a target and choose Info). Select the Build tab, then fill in Header Search Paths for headers, Library Search Paths for libraries.


For gcc, use the directory search options

    gcc -L/foo/bar/baz
    gcc -I/foo/bar/quux

The first one adds the directory /foo/bar/baz to the linker search path (libs will be found here). The second one adds the directory /foo/bar/quux to the front on the list of directories to search for headers. Mixed and multiple -I and -L options can occur in a single invocation. If you use multiple "-I"s, they are searched in left to right order and then the system directories are searched.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜