• Advertisement

• Popular Now

• 11
• 9
• 10
• 9
• 11
• Advertisement
• Advertisement
• Advertisement

Archived

This topic is now archived and is closed to further replies.

Library formats

This topic is 2175 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Visual C++ uses libraries in the .lib format, whereas all the GCC compilers use .a for there libraries. The formats are different, and I was wondering if anybody knew a way to convert between the two, or at least use the .libs with MingW32

------------------
LoungePig
OpenGUI

Share this post

Share on other sites
Advertisement
Even if it was possible, I don't think code would be compatible between VS and GCC. Lots of [b]implementation[/b] of C++ is compiler-dependant (like the way they handle function pointers for example).

Share this post

Share on other sites
MinGW and VC++ use the same library format. Really, open them up in a text editor. I was surprised to find this out myself.

Part of libz.a installed by MinGW (albiet back in the GCC 4.1 days):
[CODE]
!<arch>
/ 1264731646 0 0 0 1192 
[/CODE]

Part of zlib.lib compiled by VC++2010 yesterday:
[CODE]
!<arch>
/ 1336440513 0 5418
[/CODE]

The archiver (ar) basically acts the same when "ar p [libfile]" for both of them.

I seem to remember that MinGW was written to be compatible with VS libraries on a code level, but that was a while back so I could be misremembering, and even if I'm not they could have ditched that. Easy way to try, though; just link a VS-compiled lib to a GCC project and see if it runs.

Edit: I just realized that while the archive formats are the same, the object files contained within are most likely different, preventing them from linking with the alternative toolchain.

Share this post

Share on other sites
A thread almost 13 years old? Must be a new record.

Share this post

Share on other sites

This topic is 2175 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

This topic is now closed to further replies.

• Advertisement