工具链问题:如何添加标头/库以便编译器知道在哪里找到它?
我使用此脚本制作了一个工具链: http://gist.github.com/403608 (更多或进行较少的修改即可使其正常工作)
一切都已安装,现在当我尝试使用它进行编译时,当我 ./configure 时出现错误,它说我的 C 编译器无法创建可执行文件。我认为我的编译器只是不知道在哪里查找所有标头和库...因为它们不在 /usr/ 中,而是在 /var/sdk/usr/ 中
有没有办法告诉我的编译器也总是查看 /var/sdk/usr/ 吗?
I have made a toolchain using this script: http://gist.github.com/403608 (more or less modified to get it to work)
Everything 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
大多数配置脚本使用
LDFLAGS
和CPPFLAGS
环境变量来修改包含和库的目录搜索路径。您还可以查看编译器文档,因为它们通常也会查看环境变量。例如,gcc 在
LIBRARY_PATH
列出的目录中查找库。它还会在目录CPATH
中查找包含内容。Most configure scripts use
LDFLAGS
andCPPFLAGS
environment variables to modify directory search paths for includes and libs.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 directoriesCPATH
for includes.进入您的目标设置(按住 Control 键单击目标并选择“信息”)。选择“构建”选项卡,然后为标头填写“标头搜索路径”,为库填写“库搜索路径”。
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.
对于 gcc,请使用 目录搜索选项
第一个添加目录 / foo/bar/baz 到链接器搜索路径(将在此处找到库)。第二个将目录 /foo/bar/quux 添加到目录列表的前面以搜索标头。一次调用中可以出现混合和多个 -I 和 -L 选项。如果使用多个“-I”,则按从左到右的顺序搜索它们,然后搜索系统目录。
For gcc, use the directory search options
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.