如何将 C 库链接到 GCC
我运行以下命令
./gcc -o test -ansi test.c -L/<other dirs>/gcc/arm-linux-androideabi/4.4.3/include-fixed/
...
test.c:3:18: error: no include path in which to search for stdio.h
test.c: In function 'main':
test.c:7: warning: incompatible implicit declaration of built-in function 'printf'
这是 ls
jackie@jackie-Latitude-E6410:<Other dirs>/gcc/arm-linux-androideabi/4.4.3/include-fixed/ ls
limits.h linux README stdio.h sys syslimits.h
有什么想法吗?
I run the following
./gcc -o test -ansi test.c -L/<other dirs>/gcc/arm-linux-androideabi/4.4.3/include-fixed/
I get ...
test.c:3:18: error: no include path in which to search for stdio.h
test.c: In function 'main':
test.c:7: warning: incompatible implicit declaration of built-in function 'printf'
Here is the ls
jackie@jackie-Latitude-E6410:<Other dirs>/gcc/arm-linux-androideabi/4.4.3/include-fixed/ ls
limits.h linux README stdio.h sys syslimits.h
Any Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于包含文件,您可能需要使用
-I
而不是-L
,后者用于指定共享库和静态库本身的位置。For include files you probably want to use
-I
instead of-L
which is what you use to specify locations the shared and static libraries themselves.您应该在编译行将
-L
更改为-I
-L
用于链接库,-I
用于添加到包含搜索路径。因此,当它编译而不是链接时,您可能会遇到另一个错误,那么您将需要添加
-L
和-l
(除非您只是添加所需的完整库)路径)You should change the
-L
to-I
on the compile line-L
is for linking libraries and-I
is for adding to the include search paths.So you might get another error when it compiles and not link, then you will need to add a
-L
and a-l
(unless you just add the needed libraries with full paths)