These days I want to debug erlang's nif call c cpi, So I downloaded the source code. I mainly want to generate a mysql_nif.dll Link Library.
Win:
Decompress the source code and run libmysql In the lib directory. dll, libmysql. lib, mysqlclient. the three lib files are quite strange. Then, I asked my colleague da for a moment, and found that if I used the link libmysql. lib must have libmysql under the same directory of the generated dll. dll. If mysqlclient. lib is used, the link must be added to the Code.
# Pragma comment (linker, "/nodefaultlib: LIBCMT. lib ")
# Pragma comment (linker, "/nodefalib lib: MSVCRTD. lib ").
Then, configure the attributes in vs2010 to generate mysql_nif.dll ..
In linux:
It's easy to compile as follows.
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