• ### What is your GameDev Story?

#### Archived

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

# Library formats

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

## 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 on other sites
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 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 on other sites
A thread almost 13 years old? Must be a new record.

##### Share on other sites

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

This topic is now closed to further replies.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634136
• Total Posts
3015757
×