From: Luke D. <cod...@ho...> - 2004-07-09 08:43:09
|
----- Original Message ----- From: "Aaron W. LaFramboise" <aar...@aa...> To: <min...@li...> Sent: Friday, July 09, 2004 5:11 AM Subject: Re: [Mingw-users] Using MSVC DLLs > Marco Grubert wrote: > > This is true for all the functions exported by the DLL- none can be > > resolved. Even though they are listed in libadll.a (but with that added > > underscore). > > Any suggestions ? > > This is a binutils bug (sort of). > > I have a patch for this to binutils pending someone noticing it. :) > When I submit another dlltool patch soon, I'm going to ping it. > > As a slightly longer explanation, all C symbols in PECOFF on Win32 are > prefixed with a _. The traditional reason this is done is to prevent > conflicts between C identifiers and the identifiers of the underlying > compiler machinery. MSVC authors decided that C++ symbols should go > into a separate namespace (although prepending the mangled symbols with > a double-underscore would probably have been sufficient for practical > purposes), and so they decided a ? prefix should be used rather than the > C _ prefix, so that conflicts were not possible. Unfortunately it > requires the object tools to know about it, and as no standard (that I > am familiar with) specifies this, binutils doesn't do it. > > In the mean time, if you need this feature to get your project working, > you'll need to recompile binutils with this patch. You should be able > to do this within MSYS. The patch is at: > http://sources.redhat.com/ml/binutils/2004-06/msg00500.html > > Hope this helps. > > Aaron W. LaFramboise You may be right that binutils needs to have special handling for symbols beginning with '?' but surely this is the least of his problems? When the client code (sample.cpp) is compiled with GCC then it references symbols using GCC name mangling which is incompatible with MSVC (use nm on sample.o to see). If the interface of this DLL is compatible with plain C then the solution is to declare the functions as extern "C" when building both the DLL and EXE, but if not then the interface would need to be changed to allow mixing of compilers. http://www.mingw.org/MinGWiki/index.php/MixingCompilers Luke |