当前位置: 技术问答>linux和unix
linux下静态库的问题!!!!!急!!!
来源: 互联网 发布时间:2016-03-30
本文导语: 我把libxml2-2.6.32编译成动态链接库,然后将该动态链接库拷贝到/usr/lib目录下 写了一个测试程序 用编译命令 gcc -o example1 example1.c -lzzz(zzz为动态库的名字) 报告出错 [root@localhost xml]# gcc -o example1 example1.c -lzzz exam...
我把libxml2-2.6.32编译成动态链接库,然后将该动态链接库拷贝到/usr/lib目录下
写了一个测试程序
用编译命令
gcc -o example1 example1.c -lzzz(zzz为动态库的名字)
报告出错
[root@localhost xml]# gcc -o example1 example1.c -lzzz
example1.c:4:23: xmlmemory.h: 没有那个文件或目录
example1.c:5:20: parser.h: 没有那个文件或目录
example1.c:6:18: tree.h: 没有那个文件或目录example1.c:11: parse error before "cur"
example1.c: In function `travel':
example1.c:13: `xmlNodePtr' undeclared (first use in this function)
example1.c:13: (Each undeclared identifier is reported only once
example1.c:13: for each function it appears in.)
example1.c:13: parse error before "NodePtr"
example1.c:15: `NodePtr' undeclared (first use in this function)
example1.c:15: `cur' undeclared (first use in this function)
example1.c:22: `childptr' undeclared (first use in this function)
example1.c: In function `main':
example1.c:35: `xmlDocPtr' undeclared (first use in this function)
example1.c:35: parse error before "doc"
example1.c:36: `xmlNodePtr' undeclared (first use in this function)
example1.c:37: `doc' undeclared (first use in this function)
example1.c:44: `Node' undeclared (first use in this function)
这是什么原因,请大侠指点指点?
为什么我的头文件没有?
在编译成动态链接库的时候应该就有了把????
请问一下怎么解决?????
谢谢!!!!
写了一个测试程序
用编译命令
gcc -o example1 example1.c -lzzz(zzz为动态库的名字)
报告出错
[root@localhost xml]# gcc -o example1 example1.c -lzzz
example1.c:4:23: xmlmemory.h: 没有那个文件或目录
example1.c:5:20: parser.h: 没有那个文件或目录
example1.c:6:18: tree.h: 没有那个文件或目录example1.c:11: parse error before "cur"
example1.c: In function `travel':
example1.c:13: `xmlNodePtr' undeclared (first use in this function)
example1.c:13: (Each undeclared identifier is reported only once
example1.c:13: for each function it appears in.)
example1.c:13: parse error before "NodePtr"
example1.c:15: `NodePtr' undeclared (first use in this function)
example1.c:15: `cur' undeclared (first use in this function)
example1.c:22: `childptr' undeclared (first use in this function)
example1.c: In function `main':
example1.c:35: `xmlDocPtr' undeclared (first use in this function)
example1.c:35: parse error before "doc"
example1.c:36: `xmlNodePtr' undeclared (first use in this function)
example1.c:37: `doc' undeclared (first use in this function)
example1.c:44: `Node' undeclared (first use in this function)
这是什么原因,请大侠指点指点?
为什么我的头文件没有?
在编译成动态链接库的时候应该就有了把????
请问一下怎么解决?????
谢谢!!!!
|
在你的gcc 命令中加 -I 后面加上xml头文件的路径
还有你编译好的库文件不必放到usr/lib 下
只要在编译时指定下路径就行了
你如果只是做测试的话
现在linux系统中一般都会有libxml2的头文件和库了
只是不是交叉编译的
还有你编译好的库文件不必放到usr/lib 下
只要在编译时指定下路径就行了
你如果只是做测试的话
现在linux系统中一般都会有libxml2的头文件和库了
只是不是交叉编译的