Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
308 views
in Technique[技术] by (71.8m points)

From MinGW static library (.a) to Visual Studio static library (.lib)

I'm trying to use xlsLib for creating Excel spreadsheets from a C++ application.

The trouble is that compiling xlsLib, I give a .a file (a GCC static library, generated by MinGW). But, my application depends on another API (PhysX) that only compiles with Visual Studio.

Thus: is it possible to transform the GCC static library (xlslib.a) to a Visual Studio static library file (xlslib.lib)?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The archives of static libraries generated with MinGW are generally compatible with Visual C++ compiler/linker. So, you should be able to use them directly by adding .a files to linker input in your project properties in Visual Studio:

  1. Go to project Properties (Alt-F7).
  2. On the left box, open Configuration Properties->Linker->Input
  3. Add list of all .a archives you need to use
  4. You may need to add also MinGW's libgcc.a library

Also, there may occur problems regarding mixed C run-time libraries properties of C/C++->Code Generation->Runtime Library, but this depends on your build configuration you use with MinGW. Sometimes it is necessary to link against libmsvcrt.a from MinGW but in many (if not most) cases it causes problems.

Finally, this mixed MinGW and Visual C++ linking generally works but for C modules and it does not work for C++, as far as I know.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...