November 28, 2006

cygwin, mingw and runtime libraries

I have been trying to get gcc to compile dll's that I can use with msvc 8.0. Turns out that the accepted practice involves taking the standard mingw/cygwin install and copying and renaming library files.

The compiler always wants to link msvcrt.dll, so to link with msvcr80 we have to create a directory containing a copy of the mingw/cygwin distribution's msvcr80.a library renamed to msvcrt.a, and then specify this directory as a library path when we link.

Wouldn't it be simpler if the distribution came set up that way?

2 comments:

mmikkone said...

I've been wondering why we need implicit linking at all. By implicit I mean that you don't have specify CRT library for the linker, but instead the linker just assumes that you want to use a specific library. Why couldn't you just give the CRT library for the linker on command line.

Perhaps the current practise is to make things easier for the beginners.

mmikkone said...

I just found out an easier way to link to msvcr80.dll with mingw.

Edit the text file

c:\mingw\lib\gcc\mingw32\3.2.4\specs

and change "-lmsvcrt" to "-lmsvcr80".