Py学习  »  DATABASE

将我的C脚本连接到MySQL联机数据库时出错

chicory__ • 6 年前 • 328 次点击  

我正在尝试编写一个简单的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;
}
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/52731