1 运行create_xml.c时遇到的问题 2 3 [email protected]:~/Desktop/mxml-2.9$ ./configure --enable-threads 4 [email protected]:~/Desktop/mxml-2.9$ make 5 [email protected]:~/Desktop/mxml-2.9$ sudo make install 6 //依照以前的经验,要开启多线程的支持,编译,安装 7 8 9 10 [email protected]:~/Desktop/project_xml_mysql$ ls -l 11 total 8 12 -rw-rw-r-- 1 jason jason 1447 Sep 15 02:41 create_xml.c 13 -rw-rw-r-- 1 jason jason 1369 Sep 15 02:34 create_xml.c~ 14 //编写源代码 15 [email protected]:~/Desktop/project_xml_mysql$ gcc -o create_xml create_xml.c -lmxml 16 //usr/local/lib/libmxml.so: undefined reference to `pthread_getspecific‘ 17 //usr/local/lib/libmxml.so: undefined reference to `pthread_key_create‘ 18 //usr/local/lib/libmxml.so: undefined reference to `pthread_once‘ 19 //usr/local/lib/libmxml.so: undefined reference to `pthread_setspecific‘ 20 //usr/local/lib/libmxml.so: undefined reference to `pthread_key_delete‘ 21 collect2: error: ld returned 1 exit status 22 //可以看出是没有多线程的支持 23 [email protected]:~/Desktop/project_xml_mysql$ gcc -o create_xml create_xml.c -lmxml -lpthread 24 [email protected]:~/Desktop/project_xml_mysql$ ls 25 create_xml create_xml.c create_xml.c~ 26 //这样可以得到可执行文件 27 [email protected]:~/Desktop/project_xml_mysql$ ./create_xml 28 ./create_xml: error while loading shared libraries: libmxml.so.1: cannot open shared object file: No such file or directory 29 //运行的时候出现了另外的一个问题 30 //参考文献:http://blog.csdn.net/dikcychen2011/article/details/9765787 31 [email protected]:~/Desktop/project_xml_mysql$ cat /etc/ld.so.conf 32 include /etc/ld.so.conf.d/*.conf 33 [email protected]:/etc$ sudo vi ld.so.conf 34 [email protected]:/etc$ cat ld.so.conf 35 include /etc/ld.so.conf.d/*.conf 36 include /usr/local/lib 37 //安装上面的步骤改变etc下面的那个文件 38 [email protected]:/etc$ cd ~/Desktop/project_xml_mysql/ 39 [email protected]:~/Desktop/project_xml_mysql$ ls 40 create_xml create_xml.c create_xml.c~ 41 [email protected]:~/Desktop/project_xml_mysql$ sudo ./create_xml 42 ./create_xml: error while loading shared libraries: libmxml.so.1: cannot open shared object file: No such file or directory 43 [email protected]:~/Desktop/project_xml_mysql$ ldconfig 44 /sbin/ldconfig.real: Can‘t create temporary cache file /etc/ld.so.cache~: Permission denied 45 [email protected]:~/Desktop/project_xml_mysql$ sudo ldconfig 46 //这个ldconfig是使得配置使能 47 [email protected]:~/Desktop/project_xml_mysql$ sudo ./create_xml 48 [email protected]:~/Desktop/project_xml_mysql$ ls 49 create_xml create_xml.c create_xml.c~ creat_new_check.xml 50 //运行之后产生新的xml文件 51 [email protected]:~/Desktop/project_xml_mysql$ cat creat_new_check.xml 52 <?xml version="1.0" encoding="utf-8"?><data><node>val1</node><node>val2</node><node>val3</node><group><node>val4</node><node>val5</node><node>val6</node></group><node>val7</node><node>val8</node></data>
时间: 2024-10-25 07:50:11