当前位置: 技术问答>linux和unix
应用libxml2处理XML文件,编译成功了,但运行时报错
来源: 互联网 发布时间:2016-02-26
本文导语: 安装了libxml2 执行xml2-config --cflags 显示-I/usr/local/include/libxml2 执行xml2-config --libs 显示-L/usr/local/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl 用下面命令编译程序test1.c cc -o test1 test1.c -I/usr/local/include/libxml2 -L/usr/local/lib ...
安装了libxml2
执行xml2-config --cflags
显示-I/usr/local/include/libxml2
执行xml2-config --libs
显示-L/usr/local/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl
用下面命令编译程序test1.c
cc -o test1 test1.c -I/usr/local/include/libxml2 -L/usr/local/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl
编译未报错,生成test1
执行test1时,报错:
dynamic linker : test1 : could not open libxml2.so.2
Killed
下面是/usr/local/lib里面的文件
total 32200
-rw-r--r-- 1 root sys 4267332 Jan 24 16:04 libxml2.a
-rwxr-xr-x 1 root sys 825 Jan 24 16:04 libxml2.la
-rwxr--r-- 1 root sys 4014736 Jan 24 16:04 libxml2.so@
-rwxr--r-- 1 root sys 4014736 Jan 24 16:04 libxml2.so.2@
-rwxr--r-- 1 root sys 4014736 Jan 24 16:04 libxml2.so.2.6.23
-rwxr-xr-x 1 root sys 54820 Oct 31 2002 libz.so@
-rwxr-xr-x 1 root sys 54820 Oct 31 2002 libz.so.1@
-rwxr-xr-x 1 root sys 54820 Oct 31 2002 libz.so.1.1.4@
drwxr-xr-x 4 root root 96 Jun 15 2005 netscape
drwxr-xr-x 2 root sys 96 Jan 24 16:04 pkgconfig
-rw-r--r-- 1 root sys 235 Jan 24 16:04 xml2Conf.sh
请问这个问题怎么解决啊?
执行xml2-config --cflags
显示-I/usr/local/include/libxml2
执行xml2-config --libs
显示-L/usr/local/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl
用下面命令编译程序test1.c
cc -o test1 test1.c -I/usr/local/include/libxml2 -L/usr/local/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl
编译未报错,生成test1
执行test1时,报错:
dynamic linker : test1 : could not open libxml2.so.2
Killed
下面是/usr/local/lib里面的文件
total 32200
-rw-r--r-- 1 root sys 4267332 Jan 24 16:04 libxml2.a
-rwxr-xr-x 1 root sys 825 Jan 24 16:04 libxml2.la
-rwxr--r-- 1 root sys 4014736 Jan 24 16:04 libxml2.so@
-rwxr--r-- 1 root sys 4014736 Jan 24 16:04 libxml2.so.2@
-rwxr--r-- 1 root sys 4014736 Jan 24 16:04 libxml2.so.2.6.23
-rwxr-xr-x 1 root sys 54820 Oct 31 2002 libz.so@
-rwxr-xr-x 1 root sys 54820 Oct 31 2002 libz.so.1@
-rwxr-xr-x 1 root sys 54820 Oct 31 2002 libz.so.1.1.4@
drwxr-xr-x 4 root root 96 Jun 15 2005 netscape
drwxr-xr-x 2 root sys 96 Jan 24 16:04 pkgconfig
-rw-r--r-- 1 root sys 235 Jan 24 16:04 xml2Conf.sh
请问这个问题怎么解决啊?
|
你把/usr/local/lib加到/etc/ld.so.conf里面然后运行ldconfig -v
或者设置
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
或者设置
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib