Mac上c语言连接mysql遇到的问题
2013-07-06 15:28
696 查看
参照《Beginning Linux Programming》上的例程写了一个连接mysql的c语言小程序connect1.c。但是按照书上的编译命令无法编译。然后经过查阅资料解决了问题。记录如下:
首先书上的编译命令是:
编译不成功,始终提示directory not found。网上有人说编译器不能识别全路径制定的lib库什么的,众说纷纭。后来我尝试调换了一下命令各参数的顺序:
妈蛋就成功了。编译成功,无法运行,提示不能加载mysql库,这好像是mysql安装包的问题,就是安装没成功,编译器找不到对应的库。
我参照了这个博客的解决方案http://www.blog.bridgeutopiaweb.com/post/how-to-fix-mysql-load-issues-on-mac-os-x/
评论第一楼的解决方案好评最高,于是执行一下,我的问题也解决了。
Thank you for sharing ideas about this problem! For me none of the things above worked, unfortunately. However, I simply added a softlink from the standard MAC OS X dyld-library-path (/usr/lib/) to the libmysqlclient.18.dylib... so it can be found easily without changing much of the system. Maybe a good install process of MySQL should have done that automatically.
Here is the command:
首先书上的编译命令是:
gcc -I /usr/local/mysql/include/ connect1.c -L /usr/local/mysql/lib/ -l mysqlclient -o connect1
编译不成功,始终提示directory not found。网上有人说编译器不能识别全路径制定的lib库什么的,众说纷纭。后来我尝试调换了一下命令各参数的顺序:
gcc -I /usr/local/mysql/include/ -L /usr/local/mysql/lib/ connect1.c -o connect1 -lmysqlclient
妈蛋就成功了。编译成功,无法运行,提示不能加载mysql库,这好像是mysql安装包的问题,就是安装没成功,编译器找不到对应的库。
dyld: Library not loaded: libmysqlclient.18.dylib Referenced from: /Users/tmxu/Projects/BeginningLinuxProgramming/./connect1 Reason: image not found Trace/BPT trap: 5
我参照了这个博客的解决方案http://www.blog.bridgeutopiaweb.com/post/how-to-fix-mysql-load-issues-on-mac-os-x/
评论第一楼的解决方案好评最高,于是执行一下,我的问题也解决了。
Thank you for sharing ideas about this problem! For me none of the things above worked, unfortunately. However, I simply added a softlink from the standard MAC OS X dyld-library-path (/usr/lib/) to the libmysqlclient.18.dylib... so it can be found easily without changing much of the system. Maybe a good install process of MySQL should have done that automatically.
Here is the command:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
相关文章推荐
- mac下使用navicat连接mysql时遇到的问题
- Mac中遇到的Eclipse连接不上mySql的问题
- 关于在部署jsp网站时遇到问题:MySql连接不上、Tomcat的闪退
- VC连接mysql遇到的问题
- Mac android studio 连接svn导入项目遇到的问题
- mac 安装mysqldb组件包及mac中安装mysql-python遇到的问题
- mac装python包mysql_python遇到的问题
- 【MySQL】mac环境下使用navicat premium连接mysql乱码问题
- 掌游 新项目:我采用NH连接MySql所遇到的问题
- python3 连接 mysql 遇到乱码问题解决方案
- 转帖:使用BDC连接MySql可能遇到的问题
- MAC下安装MySql遇到的问题
- Mac下遇到的mysql问题集
- Java连接mysql中遇到的一些问题及解决方法
- MySql和VS2008连接遇到的问题
- mysql5.6连接遇到的问题
- Hibernate连接MySql遇到的几个问题
- Mac 下 MySQL 5.7 连接 navicat 中文乱码问题终极解决方案
- x64 Windows下配置C语言开发MySQL的环境遇到的问题
- java连接mysql时遇到的问题