博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C++在Ubuntu上编译mysql问题
阅读量:4621 次
发布时间:2019-06-09

本文共 589 字,大约阅读时间需要 1 分钟。

所有mysql_xxx 函数都显示为,如:

undefined reference to `mysql_init`

undefined reference to `mysql_close`

...

 

解决步骤:

1.是否有包含头文件mysql.h

如 -I /usr/include/mysql

2.是否有添加mysql对应的链接库目录

如 -L /usr/lib/mysql -l mysqlclient -lz -lm

如果还是不行,则在编译程序末尾加上 `mysql_config --cflags --libs`;

系统会自动查找mysql所依赖的内容。

如:

  g++ main.cpp logger.cpp -o test `mysql_config --cflags --libs`

 

在系统下查询 mysql_config 配置内容:

root@localhost:~#mysql_config --cflags --libs

-I /usr/include/mysql -DBIG_JSONS=1 -fno-strict-aliasing -g

-L /usr/lib -lmysqlclient -lpthread -lz -lm -lrt -ldl

 

转载于:https://www.cnblogs.com/sylar-liang/p/4561516.html

你可能感兴趣的文章
poj 1654 && poj 1675
查看>>
运维派 企业面试题1 监控MySQL主从同步是否异常
查看>>
Docker 版本
查看>>
poj 1753 Flip Game
查看>>
在深信服实习是怎样的体验(研发测试岗)
查看>>
Linux免密码登陆
查看>>
SpringMVC中文件的上传(上传到服务器)和下载问题(二)--------下载
查看>>
Socket & TCP &HTTP
查看>>
osip及eXosip的编译方法
查看>>
Hibernate composite key
查看>>
[CF Round #294 div2] D. A and B and Interesting Substrings 【Map】
查看>>
keepalived+nginx安装配置
查看>>
我的2015---找寻真实的自己
查看>>
android编译遇到问题修改
查看>>
解决Ubuntu18.04.2远程桌面Xrdp登录蓝屏问题
查看>>
Git的安装和使用教程详解
查看>>
lsof命令详解
查看>>
常用模块,异常处理
查看>>
父窗口与子窗口之间的传值
查看>>
eclipse 找不到 tomcat 的解决方案
查看>>