-2

我正在尝试编译使用 MYSQL 库的程序。这些是我的包括:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <mysql/mysql.h>

这些是错误:

/tmp/ccs0iJn4.o: In function `toMysql':
ice2mysql2.c:(.text+0x32d): undefined reference to `mysql_init'
ice2mysql2.c:(.text+0x373): undefined reference to `mysql_real_connect'
ice2mysql2.c:(.text+0x38f): undefined reference to `mysql_query'
ice2mysql2.c:(.text+0x39d): undefined reference to `mysql_close'
/tmp/ccs0iJn4.o: In function `parseGlobalStats':
ice2mysql2.c:(.text+0x3f1): undefined reference to `xmlStrcmp'
ice2mysql2.c:(.text+0x412): undefined reference to `xmlNodeListGetString'
/tmp/ccs0iJn4.o: In function `parseStreamNet':
ice2mysql2.c:(.text+0x44f): undefined reference to `xmlStrcmp'
ice2mysql2.c:(.text+0x493): undefined reference to `xmlStrcmp'
ice2mysql2.c:(.text+0x4b4): undefined reference to `xmlNodeListGetString'
ice2mysql2.c:(.text+0x4cf): undefined reference to `xmlStrcmp'
ice2mysql2.c:(.text+0x4f0): undefined reference to `xmlNodeListGetString'
ice2mysql2.c:(.text+0x50b): undefined reference to `xmlStrcmp'
ice2mysql2.c:(.text+0x52c): undefined reference to `xmlNodeListGetString'
/tmp/ccs0iJn4.o: In function `parseDoc':
ice2mysql2.c:(.text+0x557): undefined reference to `xmlParseFile'
ice2mysql2.c:(.text+0x598): undefined reference to `xmlDocGetRootElement'
ice2mysql2.c:(.text+0x5d4): undefined reference to `xmlFreeDoc'
ice2mysql2.c:(.text+0x60e): undefined reference to `xmlFreeDoc'
collect2: ld returned 1 exit status

我用这个编译:

gcc -L/usr/lib/i386-linux-gnu -lxml2 -lmysqlclient -o ice2mysql2 ice2mysql2.c

如果你想看intire程序:

该程序

我想知道发生了什么,请帮助...谢谢!

4

1 回答 1

0

您链接到的库必须在最后提及:

 gcc -L/usr/lib/i386-linux-gnu  -o ice2mysql2 ice2mysql2.c -lxml2 -lmysqlclient
于 2013-10-29T18:23:07.000 回答