Warning: resolving Func by referencing Func @ ##

I am creating a DLL with the following:

extern "C" __declspec(dllexport) void __stdcall DrawMouse(int X, int Y, int R, int G, int B) { Buffer.SetMouse(X, Y, R, G, B); } 

Then in the .def file, I added:

 LIBRARY Test ;DESCRIPTION "Test Definition File" EXPORTS DrawMouse; 

Then, when I compile, I add linker options:

 -static -static-libstdc++ -static-libgcc -Wl,--kill-at -d --input-def src\Test.def -m32 

And the result:

Warning: resolving _DrawMouse by referencing _DrawMouse @ 24

Why? Why does this warn me about permission and how can I get rid of it? For a large volume of exports, I get a big warning.

A small example:

main.cpp:

 #include <windows.h> class Input { public: void SetMouse(int X, int Y, int R, int G, int B) { /**Dummy Example**/ } }; Input Buffer; extern "C" void __stdcall SetMouse2(int X, int Y, int R, int G, int B) { /**Dummy Non-Class Example**/ } extern "C" __declspec(dllexport) void __stdcall DrawMouse(int X, int Y, int R, int G, int B) { Buffer.SetMouse(X, Y, R, G, B); } extern "C" __declspec(dllexport) void __stdcall DrawMouse2(int X, int Y, int R, int G, int B) { SetMouse2(X, Y, R, G, B); } extern "C" __declspec(dllexport) bool __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: DrawMouse(100, 100, 1, 1, 1); DrawMouse2(100, 100, 1, 1, 1); break; case DLL_PROCESS_DETACH: break; } return true; } 

Test.def:

 LIBRARY Test ;DESCRIPTION "Test Definition File" EXPORTS DrawMouse; DrawMouse2; 

Compiler Log:

 -------------- Clean: Release in Test (compiler: GNU GCC Compiler)--------------- Cleaned "Test - Release" -------------- Build: Release in Test (compiler: GNU GCC Compiler)--------------- x86_64-w64-mingw32-g++.exe -O2 -Wall -m32 -DBUILD_DLL -std=c++11 -c C:\Users\Brandon\Desktop\Test\main.cpp -o obj\Release\main.o x86_64-w64-mingw32-g++.exe -shared -Wl,--output-def=bin\Release\libTest.def -Wl,--out-implib=bin\Release\libTest.a -Wl,--dll obj\Release\main.o -o bin\Release\Test.dll -s -static -static-libstdc++ -static-libgcc -Wl,--kill-at -d --input-def Test.def -m32 -luser32 Warning: resolving _DrawMouse by linking to _DrawMouse@20 Warning: resolving _DrawMouse2 by linking to _DrawMouse2@20 Use --enable-stdcall-fixup to disable these warnings Use --disable-stdcall-fixup to disable these fixups Output size is 32.50 KB Process terminated with status 0 (0 minutes, 0 seconds) 0 errors, 2 warnings (0 minutes, 0 seconds) 

NOTE. --disable-stdcall-fixup does NOT work. That is why I am asking how to fix this and get rid of these warnings, as well as what causes them.

EDIT:

Command line with corrections on request:

 x86_64-w64-mingw32-g++.exe -O2 -Wall -m32 -DBUILD_DLL -std=c++11 -c C:\Users\Brandon\Desktop\Test\main.cpp -o obj\Release\main.o x86_64-w64-mingw32-g++.exe -shared -Wl,--output-def=bin\Release\libTest.def -Wl,--out-implib=bin\Release\libTest.a -Wl,--dll obj\Release\main.o -o bin\Release\Test.dll -s -static -static-libstdc++ -static-libgcc -Wl,--kill-at -d --input-def Test.def -m32 --disable-stdcall-fixup -luser32 

Also tried:

 x86_64-w64-mingw32-g++.exe -O2 -Wall -m32 -DBUILD_DLL -std=c++11 -c C:\Users\Brandon\Desktop\Test\main.cpp -o obj\Release\main.o x86_64-w64-mingw32-g++.exe -shared -Wl,--output-def=bin\Release\libTest.def -Wl,--out-implib=bin\Release\libTest.a -Wl,--dll obj\Release\main.o -o bin\Release\Test.dll -s -static -static-libstdc++ -static-libgcc -Wl,--kill-at -d --input-def Test.def -m32 --enable-stdcall-fixup -luser32 

Nothing works.

+4
source share
1 answer

You need to point --enable-stdcall-fixup to the linker (which automatically fixes the problem). When used with gcc or g++ this means -Wl,--enable-stdcall-fixup .

See section 2.1.1 Gnu Linker Settings for more information on these options.

+4
source

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


All Articles