GCC exports function name only from dll

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

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

I am compiling this using the Code :: Blocks GCC compiler (V3.4.5). Problem: as a result, the dll exports the decorated function name ...

 MP_GetFactory@4 

This does not load, it should just be old ...

 MP_GetFactory 

I investigated this for about 4 hours. I think -add-stdcall-alias is an opportunity to fix this. My code :: Log Lock ...

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 the right option is there? But no luck. Dependancy Walker shows only the exported name. I got it to work using __cdecl instead of __stdcall, then the name is then exported normally, but the function corrupts the stack on the call (since the caller was expecting another calling convention).

+4
source share
2 answers

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

Project / assembly options / linker / other linker options -Wl, - kill-on

... kills the @ decoration symbol, etc.

+5
source

I think it should be -Wl, - add-stdcall-alias, and the kill-at tricks will render the import library file unusable.

+1
source

Source: https://habr.com/ru/post/1304959/


All Articles