Home >Database >Mysql Tutorial >mysql c的api 调用实例_MySQL

mysql c的api 调用实例_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 14:02:10950browse

这些天想调试erlang的nif调用c cpi 所以就下载源码了,主要想生成一个mysql_nif.dll链接库。
win下:
解压源码出来,lib目录下 libmysql.dll、libmysql.lib、mysqlclient.lib三个文件,觉得挺奇怪的,,然后询问了达达同事也gg了一下,于是发现了如果使用链接libmysql.lib那么必须在生成dll同目录下有libmysql.dll。如果使用mysqlclient.lib,,那么代码必须加上链接
#pragma comment(linker,”/nodefaultlib:LIBCMT.lib”)
#pragma comment(linker,”/nodefaultlib:MSVCRTD.lib”)。
然后vs2010配置属性就可以生成mysql_nif.dll了。。

在linux下:
比较简单了,按以下编译即可。
gcc -fPIC -shared -o mysql_nif.so mysql_nif.c -I /usr/local/mysql/include/mysql -L /usr/local/mysql/lib/mysql -l mysqlclient -I /usr/local/lib/erlang/erts-5.8/include

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn