From: Luke D. <cod...@ho...> - 2003-02-19 10:59:58
|
>From: David Fraser <da...@sj...> >To: MinGW Users <min...@li...> >Subject: [Mingw-users] Using msvcrtd and problems with liboldname... >Date: Wed, 19 Feb 2003 12:32:45 +0200 > >Hi > >Earnie recently helped me link my application with msvcrtd instead of >msvcrt. >The final point reached was to add a -mmsvcrtd switch to the specs file >which then links with msvcrtd instead of msvcrt. >Then, with a very simple C program, the files link only to msvcrtd, not >msvcrt. >However, if open() or write() is referenced, the executables still contain >a link to msvcrt as well as msvcrtd. >This didn't seem to be a problem, but now it does... > >Basically in our wxWindows app, when linking with msvcrtd, we get errors >trying to write to a file. >These are reproducible in a very simple wxWindows program, linking in the >wx library statically. >(They strangely do not occur when trying to do the same thing using >standard file functions). >I suspect that the problem is that open(), write() are defined in >libmoldname, which links to >msvcrt by default. This suspicion is confirmed by the fact that using >_open, _write doesn't link in msvcrt at all. > >The solution to me seems to be to build a libmoldnamed.a which links to >msvcrtd instead of msvcrt. >Is this correct, and how should I go about doing it? That should work. To do it, get the source for mingw-runtime and look in Makefile.in for how libmoldname.a is generated: libmoldname.a: $(srcdir)/moldname-msvcrt.def $(MOLD_OBJS) $(DLLTOOL) --as $(AS) -k -U \ --dllname msvcrt.dll \ --def $(srcdir)/moldname-msvcrt.def \ --output-lib $@ $(AR) rc $@ $(MOLD_OBJS) $(RANLIB) $@ So you may do: dlltool --dllname msvcrtd.dll --def moldname-msvcrt.def --output-lib libmoldnamed.a You'll need compile string_old.c and ctype_old.c and add them to the lib with "ar" if you need the stubs they contain. Luke > >Thanks > >David > >>>Also, how can I link my app with this and not the standard libmsvcrt.a >>>(without having to use ld >>>myself - I can link a simple app using ld to specify libmsvcrtd.a.)? If I >>>just add a -lmsvcrtd to the gcc command it links in both msvcrt >>>and msvcrtd (and seems to have problems: it exists without an error in a >>>simple program after the >>>first printf...). >>> >> >>That'll require a little work on the specs file for GCC that'll recognize >>a switch (say -mmsvcrtd) that will use the debug runtime version. >> >>Something like: >>*libgcc: >>%{mthreads:-lmingwthrd} -lmingw32 -lgcc -lmoldname -lmingwex >>%{mmsvcrtd:-lmsvcrtd} %{!mmsvcrtd:-lmsvcrt} >> >>Watch the line wrap, two lines worth of specs file. >> >>Earnie. > > > > > >------------------------------------------------------- >This SF.net email is sponsored by: SlickEdit Inc. Develop an edge. >The most comprehensive and flexible code editor you can use. >Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial. >www.slickedit.com/sourceforge >_______________________________________________ >MinGW-users mailing list >Min...@li... > >You may change your MinGW Account Options or unsubscribe at: >https://lists.sourceforge.net/lists/listinfo/mingw-users _________________________________________________________________ Hotmail now available on Australian mobile phones. Go to http://ninemsn.com.au/mobilecentral/hotmail_mobile.asp |