I've lost a lot of time on this, and I believe others have too. I've done a search here and at other places on the web and still can't get it resolved.
For what I'm doing, which is COM programming (Microsoft's Component Object Model), I really, really need to have the g++/ld compiler, linker, whatever, place un-mangled, unadorned function names in the Dll I'm creating. I use CodeBlocks with MinGW for all my Windows C++ coding (I really like it and prefer it to Visual Studio Pro), but try as I might I've never been able to put a dent in this problem with *.def files and MinGW. For my COM programming if I'm making a COM Dll, I still have to use MS VStudio.
Can anyone actually tell me how to do it? I've tried both command line compiling and using the Code::Blocks Ide. When I set up the Code::Blocks Dll project with 8.05 I told it to create a def file. I've tried all different combinations. Just today doing a search on this site I found a recommendation to do this...
--def=ForUtils.def
or this...
/def:"ForUtils.def"
...and I've tried putting these things in the GUI list boxes under 'Linker Settings'.
No matter what I do, when I open up the produced binary to search for the alpha-numeric labels of various functions, I find mangled/adorned names. The issue with what I'm doing is that COM Dlls are loaded by the Windows system through a component known as the 'Service Control Manager' usually referred to as SCM or Scum. When a client requests a COM object SCM does a LoadLibrary() / GetProcAddress() call on the Dll and the function its looking for is one of various exports with very specific names which can't be mangled. The names are DllRegisterServer, DllUnregisterServer, DllGetClassObject, and DllCanUnloadNow. If I open up a working Dll produced with any of the Microsoft compilers, here is what I'll find in the Dll...
ForUtils.dll DllRegisterServer DllUnregisterServer DllCanUnloadNow DllGetClassObject
If I open up a MinGw produced binary and root around, this is what I'll eventually find...
ForUtils.dll DllRegisterServer@0 DllUnregisterServer@0 DllCanUnloadNow@0 DllGetClassObject@12
Naturally, the object can't be used, as the system can't locate it with those names. I've tried all the extern "C" __declspec(dllexport) stuff, libForUtils.def export definition file stuff, everything I can think of. Nothing works! Can anyone help me?