Jeff McClintock
Jeff McClintock

Reputation: 1261

GCC exports decorated function name only from dll

I have a dll, it exports a function...

extern "C"
int __stdcall
MP_GetFactory( gmpi::IMpUnknown** returnInterface )
{
}

I compile this with Code::Blocks GCC compiler (V3.4.5). Problem: resulting dll exports decorated function name...

MP_GetFactory@4

This fails to load, should be plain old...

MP_GetFactory

I've researched this for about 4 hours. I think --add-stdcall-alias is the option to fix this. My Code::Blocks log shows...

mingw32-g++.exe -shared -Wl,--out-implib=bin\Debug\libGainGCC.a -Wl,--dll obj\Debug\se_sdk3\mp_sdk_audio.o obj\Debug\se_sdk3\mp_sdk_common.o obj\Debug\Gain\Gain.o obj\Debug\Gain\gain.res -o bin\Debug\GainGCC.sem --add-stdcall-alias -luser32

..so I think that's the correct option in there? But no luck. Dependancy Walker show only the decorated name being exported. I got It to kinda work by using __cdecl instead of __stdcall, the name is then exported ok, but the function corrupts the stack when called (because the caller expected the other calling convention).

Upvotes: 4

Views: 2490

Answers (2)

Readon Shaw
Readon Shaw

Reputation: 439

I think it should be -Wl,--add-stdcall-alias and the "kill-at" tricks will make the generated import library file not usable.

Upvotes: 1

Jeff McClintock
Jeff McClintock

Reputation: 1261

Sorry to answer my own question, finally figured it out.

Project/Build Options/Linker/Other Linker Options -Wl,--kill-at

...kills the decoration '@' symbol etc.

Upvotes: 5

Related Questions