Q. How can an MSVC program call an MinGW DLL, and vice versa? A. Assume we have a testdll.h, testdll.c, and testmain.c. In the first case, we will compile testdll.c with MinGW, and let the MSVC-compiled testmain call it. You should use
gcc -shared -o testdll.dll testdll.c \ -Wl,--output-def,testdll.def,--out-implib,libtestdll.a to produce the DLL and DEF files. MSVC cannot use the MinGW library, but since you have already the DEF file you may easily produce one by the Microsoft LIB tool: lib /machine:i386 /def:testdll.def Once you have testdll.lib, it is trivial to produce the executable with MSVC: cl testmain.c testdll.lib Now for MinGW programs calling an MSVC DLL. We have two methods. One way is to specify the LIB files directly on the command line *after* the main program (in newer MinGW versions; MinGW GCC 2.95.2 is reported not to work). For example, after cl /LD testdll.c use gcc -o testmain testmain.c testdll.lib The other way is to produce the .a files for GCC. For __cdecl functions (in most cases), it is simple: you only need to apply the reimp tool (the original site is unavailable now, but you may download here<http://www.geocities.com/yongweiwu/reimp_new.zip> a version enhanced by José Fonseca): reimp testdll.lib gcc -o testmain testmain.c -L. -ltestdll However, the above method does not work with __stdcall functions. For MSVC will prefix an underscore to __stdcall functions while MinGW will not. The right way is to produce the DEF file using the pexports tool (downloadable here <http://www.geocities.com/yongweiwu/pexports-0.43.zip> if not found elsewhere) and filter off the first underscore by sed: pexports testdll.dll | sed "s/^_//" > testdll.def Then, when using dlltool to produce the import library, add `-U' to the command line: dlltool -U -d testdll.def -l libtestdll.a And now, you can proceed in the usual way: gcc -o testmain testmain.c -L. -ltestdll Hooray, we got it. And that is the end of this FAQ. 2001-12-21, written by Wu Yongwei 2004-7-29, last revised by Wu Yongwei 2009/4/1 Viktor Szakáts <harbour...@syenar.hu> > It worked for me after massaging it a bit:--- > set PATH=%~dp0 > pexports ace32.dll > ace32.def > dlltool -d ace32.def -D ace32.dll -k -l libace32.a > --- > > The ugly PATH trick is needed because dlltool tries to > run 'as' tool and it only finds it if in PATH, even if they are > in the same and current dir :) > > The other ugly bit is that pexports is missing from > several MinGW distros, notably the latest ones, which > are unofficial. > > So, for now this routine will have to be done by > users locally. > > The third bit is that I didn't manage to use libace32.a > to actually link a Harbour executable. [ Same missing > symbols. ] > > Brgds, > Viktor > > On Wed, Apr 1, 2009 at 6:11 PM, Massimo Belgrano <mbelgr...@deltain.it>wrote: > >> I have posted question on sysbase ng of ads >> on internet i have found >> http://es.groups.yahoo.com/group/t-gtk/message/1462 >> >> http://objectmix.com/xharbour/241009-rddads-ace32-import-libraries-mingw32.html >> In not read on yahoo group >> >1.- Vamos a extraer de la dll, por ejemplo ace32.dll, las definiciones: >> >c:\>pexports ace32.dll > ace32.def >> >Digamos, que pexports seria lo mismo que la herramienta impdef. >> >2.- Despues vamos a crear la libreria libace32.a, a partir del fichero >> >de definiciones. >> >c:\>dlltool -d ace32.def -D ace32.dll -k -l libace32.a >> >3.- Despues, tenemos que añadir la libreria a nuestro makefile. >> >-lace32 >> >> 2009/4/1 Viktor Szakáts <harbour...@syenar.hu> >> >>> Do you think to a solution that allow same hbmk2 syntax working in either >>>> enviroment? >>>> >>>> HBMK2 my.PRG ace32.lib rddads.lib -GUI -GTWVT -GTWVG -m -w0 -omio.exe >>>> >>>> >>> >>> Yes, I prefer this whereever possible. In your example you >>> should use '-lrddads' to be compiler neutral. With ace32, >>> we will see, I think MinGW should find the lib by using -lace32, >>> given that ace32.dll is placed in the lib path. But for me it then >>> complains about all missing symbols, so in the case of ace32, >>> something more needs to be done. >>> >>> Please try to get information from the internet or from Advantage, >>> as I won't be able to deal with this (I'm no ace32 user). If >>> something useful can be done with this in hbmk2, I'll try to >>> to implement it. >>> >>> Brgds, >>> Viktor >>> >>> >>> _______________________________________________ >>> Harbour mailing list >>> Harbour@harbour-project.org >>> http://lists.harbour-project.org/mailman/listinfo/harbour >>> >>> >> >> >> -- >> Massimo Belgrano >> >> Analisi e sviluppo software per Lan e Web - Consulenza informatica - >> Formazione >> Delta Informatica S.r.l. http://www.deltain.it/ +39 0321 455962 >> >> _______________________________________________ >> Harbour mailing list >> Harbour@harbour-project.org >> http://lists.harbour-project.org/mailman/listinfo/harbour >> >> > > _______________________________________________ > Harbour mailing list > Harbour@harbour-project.org > http://lists.harbour-project.org/mailman/listinfo/harbour > > -- Massimo Belgrano Analisi e sviluppo software per Lan e Web - Consulenza informatica - Formazione Delta Informatica S.r.l. http://www.deltain.it/ +39 0321 455962
_______________________________________________ Harbour mailing list Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour