From: David F. <da...@sj...> - 2003-02-19 11:10:04
|
Luke Dunstan wrote: > >> 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) $@ Thanks Luke, so I was on the right track... This seems to work for me (see other message). > > 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. I presume the MOLD_OBJS above includes these anyway... David |