[英]What causes difference in mangled names when compiling on the same compiler (vc12)?
I am currently trying to compile and link the CppUTest library with my project. 我目前正在尝试编译CppUTest库并将其与我的项目链接。 I use CMake to create a Visual Studio 2013 Solution for the CppUTest-library and it builds.
我使用CMake为CppUTest库创建了Visual Studio 2013解决方案,并且该库得以构建。
However, when I link the created CppUTest.lib to my application I get an linker error telling me that it can not find multiple symbols like 但是,当我将创建的CppUTest.lib链接到我的应用程序时,出现链接器错误,告诉我它找不到多个符号,例如
??0Utest@@QAE@XZ)
or 要么
?RunAllTests@CommandLineTestRunner@@SAHHPAPAD@Z
Now when I use dumpbin.exe on the lib and option /LINKERMEMBER I get a list of symbols in the library that includes the names 现在,当我在lib和选项/ LINKERMEMBER上使用dumpbin.exe时,会在库中获得包含名称的符号列表。
??0Utest@@QEAA@XZ
and 和
?RunAllTests@CommandLineTestRunner@@SAHHPEAPEAD@Z
So the names that actually exist are slightly different to the names that my projects expects and I have no idea what causes this problem. 因此,实际存在的名称与我的项目期望的名称略有不同,并且我不知道是什么导致了此问题。 Is there any compile option that causes these changes or do I use a different compiler although I think it is the same?
是否有引起这些更改的编译选项,或者尽管我认为相同,我是否使用其他编译器?
Run the undname.exe utility from the Visual Studio Command Prompt. 从Visual Studio命令提示符运行undname.exe实用程序 。 You get:
你得到:
Undecoration of :- "??0Utest@@QAE@XZ"
is :- "public: __thiscall Utest::Utest(void)"
and 和
Undecoration of :- "??0Utest@@QEAA@XZ"
is :- "public: __cdecl Utest::Utest(void) __ptr64"
Clear enough that this is the default constructor of the Utest class. 足够清楚,这是Utest类的默认构造函数。 Note how the calling convention is different, __thiscall vs __cdecl.
请注意__thiscall与__cdecl的调用约定有何不同。 And how the library version has the __ptr64 attribute.
以及库版本如何具有__ptr64属性。
You see that attribute appear on 64-bit functions. 您会看到该属性出现在64位函数中。 x64 has only one calling convention and does not distinguish between __cdecl and __thiscall.
x64仅具有一个调用约定,不能区分__cdecl和__thiscall。
So it should start to get obvious, the linker wants the first one, the 32-bit version of the constructor. 因此,它应该开始变得显而易见,链接器需要第一个,即构造函数的32位版本。 The 64-bit version you supplied can never work since you cannot mix 32-bit and 64-bit code.
您提供的64位版本永远无法使用,因为您无法混合使用32位和64位代码。 There should also be a loud warning about that, don't ignore such warnings.
对此也应该有一个很大的警告,不要忽略这些警告。
Link to the 32-bit build of this library to fix your problem. 链接到此库的32位版本以解决您的问题。 Or build the x64 version of your program.
或构建程序的x64版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.