Using libraries compiled with GCC in a VisualC++ project (and vice versa)

你。 提交于 2019-12-08 09:58:52

问题


It's possible to use code (and libraries) compiled with VisualC++ (so with .lib extension) in a project that will use GCC as compiler (and vice versa)? Or I have to rebuild them?
I'm trying to use SOCI 3.1 libraries that I have compiled with VisualC++ in a project that has GCC as compiler, but I'm getting some errors, and I don't know why..


回答1:


You have to produce binaries for GCC using MinGW tools: reimp and dlltool. Here is MinGW wiki with complete explanation of the procedures: MSVC and MinGW DLLs

Short example:

reimp -d libmysql.lib
dlltool -k --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a
reimp libmysql.lib

By the way, here is related thread on SOCI users mailing list which: MySQL Build fails. Look for useful links given in the thread.



来源:https://stackoverflow.com/questions/13664882/using-libraries-compiled-with-gcc-in-a-visualc-project-and-vice-versa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!