在LInux上安装:mysql C connector :How to install MySQL Connector/C on Mac OS X?
来源:互联网 发布:淘宝刷流量会封店吗 编辑:程序博客网 时间:2024/05/18 22:44
1.问题:
the problem:
不知道应该把那个从mysql官方网站下载 mysql Connector /c 文件放在本地机子的什么地方,还是用来安装:能使自己开发的应用能方便地使用这些库,和接口。
Hey there,
I'm writing an app in C that requires MySQL interaction, so I downloaded the Connector/C archive from the official website, and it contains bin, lib and include folders, but I don't know where to install them.I could copy the include files into my project folder, but where can I put the lib file so that my compiled binary (and other binaries) can find it?
Thanks in advance!
答案:
the answer:
首先, 将 tar file,解压,然后:
其中位于lib 中的文件拷贝到 /usr/local/lib中
位于 include中的文件拷贝到 /usr/local/include中
位于bin中的文件拷贝到 /usr/local/bin 中;
注意: /usr/.. 文件夹可能时不可见的,所以,以上操作,要通通命令行来完成,祝你好运!
其次,在编译时,不要忘了链接库的选项:
方法1:采用动态链接库编译:
采用动态链接库的编译:最后附上一个编译代码操作:
gcc -o db.o db.c -lmysql
方法2: 采用静态库来编译: (生成的文件可能比较大,嘿嘿 )
这个方法用动态连接库,比较那啥一点吧,看喜好,编译进去也行,2M多吧。
gcc -o db.o db.c /usr/local/lib/libmysqlclient.a
方法3: 将连接器转入你的工程中
在你没有进行以上操作时,你也可以通过以下方法通过编译: 通过指定链接库的路径
gcc -o db.o db.c -L mysql_connector_path/lib -l mysql
其中: mysql_connector_path 是你的mysql连接器所在的目录,通过 -L 选项来指定动态链接库的路径 ,这就是说通过在工程中包含该连接器目录,也能实现通过编译,更甚者把整个静态库都编译应用如方法2所采用的策略。
2 Answers
This is confusing, isn't it.. don't know why they don't make this more clear.
The lib/ files go in /usr/local/libThe include/ files go in /usr/local/includeThe bin/ files go in /usr/local/bin
The /usr/.. directory isn't visible through finder afaik so you have to go at it via commandline. Best of luck
Also, in your Xcode project, make sure you add a Linked Library by going to your Target's settings, General, then adding Linked Library "libmysqlclient.dylib"
Hey, on MySQL site you have a short presentation on how to install C connector for MySQL. You can access it here:http://dev.mysql.com/doc/refman/5.1/en/connector-c-building.html
本文链接:http://stackoverflow.com/questions/4615442/how-to-install-mysql-connector-c-on-mac-os-x
- 在LInux上安装:mysql C connector :How to install MySQL Connector/C on Mac OS X?
- MySQL Connector C
- Linux下安装使用mysql connector(C++)
- Linux下安装使用mysql connector(C++)
- linux mysql-connector-c++-1.1.5 编译
- MySQL Connector/C++(一)
- 在ubuntu上安装mysql : How to install MySQL on ubuntu(转)
- iOS 如何在苹果电脑上安装svn 服务器(how to install svn server on the computer of mac os x)
- iOS 如何在苹果电脑上安装svn 服务器(how to install svn server on the computer of mac os x)
- ubuntu12.04安装mysql-connector-c-6.1.6和mysql-connector-cpp-1.1.6
- Linux mysql C 编程——connector/c
- How to install subclipse on Mac OS X
- How to Install Subversion on Mac OS X
- How To Install MongoDB On Mac OS X
- How to install Maven on Mac OS X Mavericks (10.9)
- mac 下安装python3 的mysql connector
- Mac平台安装mysql-connector-python
- Linux为Mysql安装Mysql-connector
- [EntLib]微软企业库5.0 学习之路——第十步、使用Unity解耦你的系统—PART2——了解Unity的使用方法(2)
- 【转贴】vector vs deque
- mybatis3.0.2整合spring3.0
- 新的目标
- 重现TortoiseSVN客户端的用户名密码验证框--转载
- 在LInux上安装:mysql C connector :How to install MySQL Connector/C on Mac OS X?
- 移位操作的妙用
- java常见错误以及可能原因
- Reapter入门1
- serv-u右下角有个黄色感叹号闪动
- DSP2812的标准CMD文件
- Myeclipse中编译出现的问题,没怎么看懂什么意思
- 利用Tomcat建立多个Web Server的方法
- Object.clone()方法