我有一个 VC++ 代码(使用 VS2008 构建),它使用了一些静态库(在编译时静态链接的 *.lib 文件)。
为了便于理解,我们将我的 EXE 代码称为“AAA.EXE”,并将 lib 文件称为“A.lib”、b.lib 等...
AAA.EXE代码和静态库代码都是使用VS2008构建的。
我发现我的“AAA.EXE”在 32 位版本中工作正常,并且当 AAA.EXE 在 64 位模式下构建时显示以下链接器错误。
当然,我已经在 64 位模式下重建了静态库,并在 AAA.EXE 中提供了 lib 路径,如下所示::“对应于 AAA.EXE -> 链接器 -> 常规/输入的项目配置属性”。
这个链接器错误确实困扰了我很长时间。任何帮助是极大的赞赏。
Logger.lib(Loggerr.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall CWTTLogger::CWTTLogger(void)" (__imp_??0CWTTLogger@@QAE@XZ)
1>Logger.lib(Logger.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall CWTTLogger::~CWTTLogger(void)" (__imp_??1CWTTLogger@@UAE@XZ)
1>Logger.lib(Logger.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: long __thiscall CWTTLogger::FunctionA(unsigned short *,long *)" (__imp_?FunctionA@CWTTLogger@@QAEJPAGPAJ@Z)
1>Logger.lib(Logger.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: long __thiscall CWTTLogger::FunctionB(unsigned short *,long)" (__imp_?FunctionB@CWTTLogger@@QAEJPAGJ@Z)
1>Logger.lib(Logger.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: long __thiscall CWTTLogger::FunctionC(unsigned short *,unsigned long,unsigned short *,long)" (__imp_?FunctionC@CWTTLogger@@QAEJPAGK0J@Z)
1>Logger.lib(Logger.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: long __cdecl CWTTLogger::FunctionD(unsigned long,long,...)" (__imp_?FunctionD@CWTTLogger@@QAAJKJZZ)
1>Logger.lib(Logger.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: long __thiscall CWTTLogger::FunctionE(unsigned short *,long)" (__imp_?FunctionE@CWTTLogger@@QAEJPAGJ@Z)
1>C:\Users\User1\Documents\XYZ\Code\64bit\aaa.exe: fatal error LNK1120: 7 unresolved externals
还要添加::
I have done 2 changes in the settings to make my AAA.exe code 64-bit from 32-bit::
1)
2)
当然,代码兼容 32 位和 64 位。 VC2008 中的这 2 个设置更改是否完成以使 32 位 AAA.exe 代码成为 64 位构建?
通过查看另一个 stackoverflow 链接,我发现“项目配置属性 -> 链接器 -> 高级 -> 目标计算机默认为“未设置”中还有一个设置
如果我使目标机器==“MACHINEx64”,我会得到一种不同类型的错误,这是我之前遇到的::
“致命错误 LNK1112:模块机器类型‘X86’与目标冲突
机器类型“x64”
我真的不清楚是否应该将链接器选项中的“目标机器”字段设置为“未设置”或“MACHINEx64”?
如果是“是”,我需要弄清楚如何解决这个问题。