C++ 警告:通过链接到Func解析Func@##

C++ 警告:通过链接到Func解析Func@##,c++,C++,我正在使用以下内容构建DLL: extern "C" __declspec(dllexport) void __stdcall DrawMouse(int X, int Y, int R, int G, int B) { Buffer.SetMouse(X, Y, R, G, B); } 然后在.def文件中,我添加了: LIBRARY Test ;DESCRIPTION "Test Definition File" EXPORTS DrawMouse; 然后在编译时,添加链接器选

我正在使用以下内容构建DLL:

extern "C" __declspec(dllexport) void __stdcall DrawMouse(int X, int Y, int R, int G, int B)
{
    Buffer.SetMouse(X, Y, R, G, B);
}
然后在.def文件中,我添加了:

LIBRARY Test
;DESCRIPTION "Test Definition File"
EXPORTS

DrawMouse;
然后在编译时,添加链接器选项:

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

警告:通过链接到来解析\u DrawMouse_DrawMouse@24

为什么??为什么它警告我要解决问题,我如何才能摆脱它?对于大量的出口,我得到了大量的警告

小示例:

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;
}
编译器日志:

-------------- 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)
注意:--禁用stdcall fixup不起作用。这就是为什么我要问如何解决这个问题,消除这些警告,以及是什么导致了这些警告

编辑:

命令行,并按要求进行修复:

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 
还尝试:

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 

两者都不起作用。

您需要向链接器提供
--enable stdcall fixup
(这会自动解决问题)。与
gcc
g++
一起使用时,这意味着
-Wl,--enable stdcall fixup


有关这些选项的详细信息,请参阅的第2.1.1节

调用DrawMouse的源代码是什么样子的?特别是声明它的头文件…感谢您花时间回复。我用一个示例更新了我的帖子,并用命令更新了编译器日志。您是否尝试了
--启用stdcall fixup
,正如它告诉您的那样-它说“禁用”并不能满足您的需要。请尝试
-Wl,--启用stdcall fixup
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