【发布时间】:2016-01-29 15:28:51
【问题描述】:
我正在尝试使用 Eclipse 在我的 Mac 上开发一个 c 程序,但在包含 mysql.h 的最基本任务上遇到了困难
为了完整起见,这是我的代码:
#include <stdio.h>
#include <stdlib.h>
#include <mysql.h>
int main(void) {
printf("MySQL client version: %s\n", mysql_get_client_info());
return EXIT_SUCCESS;
}
我尝试了很多方法:
#include <mysql.h>
#include "mysql.h"
#include <mysql/mysql.h>
#include "mysql/mysql.h"
但是我在编译“'mysql/mysql.h' file not found”时总是收到消息
在包含中我什至尝试了以下方法,直接引用文件:
#include = "/usr/local/mysql-5.7.9-osx10.9-x86_64/include/mysql.h"
无论我尝试做什么,消息总是“找不到'mysql/mysql.h'文件”
这是 GCC C 编译器脚本:
Invoking: GCC C Compiler
gcc -I/usr/local/
-I/usr/local/mysql-5.7.9-osx10.9-x86_64/include
-I/usr/local/mysql-5.7.9-osx10.9-x86_64
-I/usr/local/mysql-5.7.9-osx10.9-x86_64
-I/usr/local/mysql-connector-c-6.1.6-osx10.8-x86_64/include
-I/usr/local/mysql-connector-c-6.1.6-osx10.8-x86_64
-O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/TestConsole2.d"
-MT"src/TestConsole2.d" -o "src/TestConsole2.o" "../src/TestConsole2.c"
../src/TestConsole2.c:14:10: fatal error: 'mysql/mysql.h' file not found
#include <mysql/mysql.h>
mysql.h 可以在我的系统上的 /usr/local/mysql-5.7.9-osx10.9-x86_64/include/mysql.h 中找到
只是要添加一个注释...我正在扩展 Centos 6 服务器上的当前 c 程序,我的目的是在 Eclipse 中在我的 Mac 上构建模块,测试它们,然后将模块集成到程序中服务器。
谢谢
【问题讨论】:
-
再补充一点,我重新启动了 Eclipse,现在收到一条不同的消息:架构 x86_64 的未定义符号:"_mysql_get_client_info",引用自:TestConsole2.o ld 中的 _main:符号不是为架构 x86_64 找到