关于ddbi的问题

tomqyp 2007-03-24
原因搞清楚了,原来是调用约定的问题,mysql导出的方法名可能是用def文件指定的,而在ddbi中,根据extern (windows)的约定会用_mysql_free_result@4的方法来引用函数名

按照qizi的方法,重生成一个lib就OK了
qiezi 写道

1、从dll生成def文件
2、在def文件中使用alias改名
3、从def生成lib

网上有一些,比如这篇http://www.digitalmars.com/d/archives/digitalmars/D/23719.html
jinheking 2007-03-28
这个问题现在好像没有人搞的明白

是不是使用D语言的都不使用数据库?
qiezi 2007-03-28
工作量大亚。。
heromyth 2007-04-06
贴一个别人在利用mingw来调用mysql库时的做法:

引用

By the way, some of this might be the wrong terminlogy or whatev from my lack of experience here...

1. Copy the libmySQL.dll file from mysql folder/bin/ to the directory you're working in (or just use absolute paths of

"C:\...") and run this line in gcc:

pexports libmySQL.dll | sed 's/^_//' > libmySQL.def

2. This will list all the function names that you can call using the dll.

3. Run this line (absolute addresses if necessary), the -k option is important!

dlltool --input-def libmySQL.def --dllname libmySQL.dll --output-lib libMySQLclient.a -k

4. Now that we have *a* libmysqlclient.a file we can try compiling the program with a line similar to the one below

(revolution was the name of my program):


g++ revolution.cpp -lws2_32 -lmysqlclient -o revolution.exe

5. You will now see a undefined references for each of the functions you called that reside in the mysqlclient dll. After the

functions there is also an @4 or @32 and so on, go back to your libmySQL.def file and add the @4 or @32 to the end of the

functions. Next go back and repeat steps 3 + 4. (I don't understand why we have to do this though so -anyone wish to

explain?)

...and voila! Compilation with gcc on a Windows machine!

Notes: don't forget to include the <winsock.h> header and link it to the ws2_32 library!
Global site tag (gtag.js) - Google Analytics