Use libraries compiled with visual studio in an application compiled by g++ (mingw)

旧街凉风 提交于 2019-12-28 14:00:37

问题


Is it possible to use a library compiled by visual studio in an application compiled by g++ (mingw) on Windows?


回答1:


  • If the library is written in C++ and exposes a C++ interface: no (because the name-mangling differs between g++ and VC++).

  • If the library is a static library written in C (or with an extern "C" interface): yes, but certain caveats apply.

  • If the library is a DLL with a C interface: yes, but you'll have to create your own import library.




回答2:


Also see the discussion for question QT/mingw32 undefined reference errors… unable to link a .lib




回答3:


From a technical standpoint, there isn't any reason you shouldn't be able to (it's all x86 after all). As for in practice, there are a number of tools for converting between library and object file formats. If you can find the correct one and deal with any naming, calling convention and structure layout differences (I don't know that you will or won't need to deal with any of that) you should be good.



来源:https://stackoverflow.com/questions/1138170/use-libraries-compiled-with-visual-studio-in-an-application-compiled-by-g-min

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