Can';升级到5.6后找不到mysql/mysql.h
昨天,我使用上面的说明将mysql从5.5升级到5.6,一切都很顺利,mysql客户端连接正常,我没有丢失任何数据或任何类似的错误 今天我去做一个使用mysql库的C程序。我的make失败了,因为我没有从Can';升级到5.6后找不到mysql/mysql.h,mysql,c,makefile,Mysql,C,Makefile,昨天,我使用上面的说明将mysql从5.5升级到5.6,一切都很顺利,mysql客户端连接正常,我没有丢失任何数据或任何类似的错误 今天我去做一个使用mysql库的C程序。我的make失败了,因为我没有从mysql\u-config--cflags和mysql\u-config--libs中获得正确的标志,我已经修复了这些标志。现在,我的make文件具有如下定义的标志: mysqlflags = -I/opt/mysql/server-5.6/include -fPIC -g -fabi-ve
mysql\u-config--cflags
和mysql\u-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
所以我继续检查了我的include文件夹,果然没有标题:
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`
如果我查找一个目录,在include文件夹中我有
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,我就说,哦,好吧,只是放错地方了。我试着做了一个测试
#包括
,看看它是否会把它捡起来,不要掷骰子。我尝试将mysql.h文件复制到mysql/文件夹,但也没有做任何事情,当我找到mysql.h时,它也只显示include文件夹中的文件
有没有人能给我介绍一些关于mysql 5.6开发与5.5开发的变化的文档?他没有说任何我还没做过的事
编辑:
这是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省略帧指针-fno严格别名-DMY\u PTHREAD\u FASTMUTEX=1
这就是我用来编译的,但仍然会得到您添加的错误
/opt/mysql/server-5.6/include/mysql
作为include路径,然后在头文件中,您可以#include
。这是相对于include路径的,因此(除了默认的include路径之外),编译器正在查找具有该路径的文件
/opt/mysql/server-5.6/include/mysql/mysql/mysql.h
它找不到的。您应该将代码更改为just#include
,或者将传递给编译器的include路径更改为/opt/mysql/server-5.6/include
编辑:
对不起,我刚刚意识到,mysql.h
位于/opt/mysql/server-5.6/include/mysql.h
,而不是/opt/mysql/server-5.6/include/mysql.h
。
您必须同时执行这两项操作:添加
/opt/mysql/server-5.6/include
作为包含路径和将代码更改为#include
您确定要将所有标志传递给编译器吗?如果我发布生成文件的输出以验证这一点,会有帮助吗?完整的生成文件在这里:这两者之间的唯一区别是什么我的局部变量是mysqlflags
和mysqllib
变量。我已经尝试了这两种方法,都只是执行#include
并将路径更改为just have/include
,最后,同样的问题是,它找不到mysql。抱歉,我把它弄混了。请两者都做好吗?我还编辑了答案。酷。这就解决了这个问题,尽管它迫使我在所有cc调用中包含$(mysqlflags),只要包含db.h,这对我来说很奇怪,因为我以前不需要这样做。谢谢你!我想之前,MySQL头文件位于默认包含路径的某个位置。将自动找到mysql.h。但是现在,由于它位于不同的位置,您必须告诉编译器在哪里可以找到它。当我使用apt get before(对于5.5)安装所有东西时,我非常确定它安装到了/usr/include中,而不是现在的/opt目录中。我可以把东西搬来搬去,但我觉得我现在很好。mysql和其他程序有时交互的方式很容易被屏蔽。谢谢你的帮助!