【发布时间】:2014-02-27 22:45:34
【问题描述】:
昨天我使用this page 上的说明将 mysql 从 5.5 升级到 5.6,一切正常,mysql 客户端连接,我没有丢失任何数据或类似的坏事。
今天我开始编写一个使用 mysql 库的 C 程序。我的制作失败了,因为我没有来自mysql_config --cflags 和mysql_config --libs 的正确标志,我已经修复了这些标志。所以现在我的make文件有这样定义的标志:
mysqlflags = -I/opt/mysql/server-5.6/include -fPIC -g -fabi-version=2 -fno-omit-frame- pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
mysqllibs = -L/opt/mysql/server-5.6/lib -lmysqlclient -lpthread -lm -lrt -ldl
但是当我编译时出现错误:
In file included from ./headers/controllers/comments.h:12:0,
from src/controllers/comments.c:1:
./headers/db.h:4:26: fatal error: mysql/mysql.h: No such file or directory
所以我继续检查了我的包含文件夹,果然没有标题:
ls /opt/mysql/server-5.6/include/mysql
client_authentication.h innodb_priv.h plugin_auth_common.h plugin_ftparser.h.pp service_my_plugin_log.h service_thd_alloc.h
client_plugin.h plugin_auth.h plugin.h service_my_snprintf.h service_thd_wait.h
client_plugin.h.pp plugin_audit.h plugin_auth.h.pp plugin_validate_password.h service_mysql_string.h service_thread_scheduler.h
get_password.h plugin_audit.h.pp plugin_ftparser.h psi services.h thread_pool_priv.h`
如果我查找一个目录,则在包含文件夹本身中
ls /opt/mysql/server-5.6/include/
big_endian.h keycache.h my_byteorder.h my_global.h mysql_com_server.h mysql_version.h plugin_validate_password.h typelib.h
byte_order_generic.h little_endian.h my_compiler.h my_list.h mysqld_ername.h my_sys.h sql_common.h
byte_order_generic_x86_64.h m_ctype.h my_config.h my_net.h mysqld_error.h my_xml.h sql_state.h
byte_order_generic_x86.h m_string.h my_dbug.h my_pthread.h mysql_embed.h plugin_audit.h sslopt-case.h
decimal.h my_alloc.h my_dir.h mysql mysql.h plugin_ftparser.h sslopt-longopts.h
errmsg.h my_attribute.h my_getopt.h mysql_com.h mysql_time.h plugin.h sslopt-vars.h
看到那里的 mysql.h 让我说,哦,好吧,它只是在错误的地方。我试着做一个
#include <mysql.h> 看看它是否会捡起它,没有骰子。我尝试将 mysql.h 文件复制到 mysql/ 文件夹,但这也没有做任何事情,当我执行 locate mysql.h 时,它也只显示了包含文件夹中的那个。
谁能告诉我一些关于 mysql 5.6 与 5.5 开发变化的文档? documentation 没有说我还没有做过的事情
编辑: 这是makefile输出的相关部分
cc -I/opt/mysql/server-5.6/include/mysql -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1 -I./headers -std=gnu99 -pedantic -Wall -Wextra -Werror -g -c src/database/db.c -o obj/db.o
In file included from src/database/db.c:1:0:
./headers/db.h:4:26: fatal error: mysql/mysql.h: No such file or directory
compilation terminated.
我还重新运行了mysql --cflags 以确保我在上面写错了,实际输出是
-I/opt/mysql/server-5.6/include/mysql -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
这就是我用来编译但仍然收到错误的东西
【问题讨论】:
-
您确定将所有标志传递给编译器吗?
-
如果我发布我的 makefile 的输出来验证这一点会有帮助吗?
-
完整的makefile在这里:github.com/EJEHardenberg/green-serv/blob/master/Makefile和我本地的唯一区别是
mysqlflags和mysqllib变量。