交叉编译arm-linux-gcc -l参数和-L参数为什么按网友教程还是找不到.h

exikee 2014-08-01 09:23:57
我把sqlite3.h放在.c同目录然后去掉-l才能生成,为什么没法用-l定位.h??
网上引用.h时用的< >尖括号,我换成“”并且同目录能编译,不知为何

以下是网上资料:

应用程序的交叉编译:
arm-softfloat-linux-gnu-gcc name.c -o db.out -lsqlite* -L/home/hzc/new/lib -I/home/hzc/new/include
默认的情况下,是执行动态编译,编译生成的文件比静态编译小得多,因为我们是在开发板上运行,之前已经拷贝了库文件到根文件系统里,所以这里我们采用默认的动态编译方式就行了,-lsqlite* 是指定库名,-L/home/hzc/new/lib 是指定库的搜索目录,new也就是我们刚才SQLite的安装目录,-I/home/hzc/new/include 是指定头文件的搜索目录,我们在name.c文件中头文件包含形式为 #include<sqlite*.h>,还可以把头文件拷到但前name.c同目录下或者包涵时把路径也写上,这样编译时就可以不需要 –I选项了。如果没做好前面这些工作编译是通不过的,会出错误:sqlite*.h:没有这个文件或目录,提示没有找到库文件等问题。


root@ubuntu:~/sqlite3-arm# arm-linux-gcc test.c -o test -L/home/sec/sqlite3-arm/lib -lsqlite3
test.c:3:21: error: sqlite3.h: No such file or directory
test.c: In function 'main':
test.c:23: error: 'sqlite3' undeclared (first use in this function)
test.c:23: error: (Each undeclared identifier is reported only once
test.c:23: error: for each function it appears in.)
test.c:23: error: 'db' undeclared (first use in this function)
test.c:33: warning: incompatible implicit declaration of built-in function 'exit'
test.c:45: warning: incompatible implicit declaration of built-in function 'exit'
test.c:51: error: 'SQLITE_OK' undeclared (first use in this function)
...全文
809 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhxianbin 2014-08-01
  • 打赏
  • 举报
回复
arm-linux-gcc test.c -o test -I/home/sec/sqlite3-arm/include -L/home/sec/sqlite3-arm/lib -lsqlite3
  • 打赏
  • 举报
回复
Is this the first time you ever compiled using gcc? root@ubuntu:~/sqlite3-arm# arm-linux-gcc test.c -o test -L/home/sec/sqlite3-arm/lib -lsqlite3 Where is the -I/.... option on the command line? As for the include directive: In the C standard, section 6.10.2, paragraphs 2 to 4 state: A preprocessing directive of the form #include <h-char-sequence> new-line searches a sequence of implementation-defined places for a header identified uniquely by the specified sequence between the < and > delimiters, and causes the replacement of that directive by the entire contents of the header. How the places are specified or the header identified is implementation-defined. A preprocessing directive of the form #include "q-char-sequence" new-line causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the " delimiters. The named source file is searched for in an implementation-defined manner. If this search is not supported, or if the search fails, the directive is reprocessed as if it read #include <h-char-sequence> new-line with the identical contained sequence (including > characters, if any) from the original directive.
exikee 2014-08-01
  • 打赏
  • 举报
回复
晕,把-I大写i看成小写L了,字体问题

23,121

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧