我正在尝试编写一个简单的C脚本,它可以连接到一个在线MySQL数据库。我尝试使用Connector/C(libmysqlclient),下载者
https://dev.mysql.com/downloads/connector/c/
但不要工作。
库被识别,但当我从终端编译时,结果是:
Undefined symbols for architecture x86_64: "_mysql_init", referenced from: _main in test.o ld: symbol(s) not found for architecture x86_64
我试着纠正上面描述的错误,但是我无法用任何帮助来解决这个问题。
这是我的代码测试.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mysql.h>
#define SIZE 30
int main(int argc, char** argv) {
/* connect to database */
MYSQL mysql;
if(mysql_init(&mysql) == NULL){
printf("Error\n");
return 0;
}
/* other code */
return 0;
}