* OS version ( Windows XP )
* gcc version ( 3.4.2 )
* ld version ( 2.15.94 )
* mingw-runtime version ( 3.9 )
* w32api version ( 3.6 )
I have a program that loads a dll explicitly using LoadLibrary() and GetProcAddress(). GetProcAddress uses the UNDECORATED function name in the dll call.
When the dll is compiled using dllwrap.exe and the option --add-stdcall-alias, the dll is called without a problem.
When the dll is compiled using g++ with the -shared option and --add-stdcall-alias, the GetProcAddress fails with "The specified procedure could not be found." When I add the @16 suffix to the function name it is called correctly. It seems like the --add-stdcall-alias doesn't have an effect when g++ is used with the -shared option.
Following is a copy of the command line used to call the linker. The file libAStyle.a is not used in linking the calling program.
-----------------------------------------------
g++.exe -shared ../objd/ASBeautifier.o ../objd/ASEnhancer.o ../objd/ASFormatter.o ../objd/ASResource.o ../objd/astyle_main.o -L"C:/_jpFiles/Programs/Dev-Cpp/Lib" --add-stdcall-alias --no-export-all-symbols -s -Wl -Wl,--out-implib,../bin/libAStyle.a -o ../bin/AStyle.dll
Creating library file: ../bin/libAStyle.a
Execution terminated
Compilation successful
Logged In: YES
user_id=11494
Originator: NO
--add-stdcall-alias is a linker, not a compiler, option.
You should have gotten a warng like:
unrecognized command line option "-fadd-stdcall-alias"
Try using -Wl,--add-stdcall-alias
Danny
Logged In: YES
user_id=826897
Originator: YES
Thanks, that fixed the problem.
But...
there was no warning or error when it was sent thru wrong. There was just a run-time error when the function couldn't be located.
Logged In: YES
user_id=826897
Originator: YES
I did some more testing and found the following:
--add-stdcall-alias works only if there is no space after the comma
-Wl,--add-stdcall-alias
if there is a space
-Wl, --add-stdcall-alias
or if it is placed anywhere else in the area it doesn't seem to work.
Again, it compiles OK, but it cannot locate the function at run-time.
Logged In: YES
user_id=11494
Originator: NO
Worhs as per documentation, so not a bug.