未解决的外部符号错误仅发生在 64 位模式而不是 32 位构建中 [英] Unresolved external symbol error occurring only in 64-bit mode and not in 32-bit build

查看:19
本文介绍了未解决的外部符号错误仅发生在 64 位模式而不是 32 位构建中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 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) : 错误 LNK2001: 未解析的外部符号 "__declspec(dllimport) public: __thiscall CWTTLogger::CWTTLogger(void)" (__imp_??0CWTTLogger@@QAE@XZ)1>Logger.lib(Logger.obj):错误 LNK2001:未解析的外部符号__declspec(dllimport) public:虚拟 __thiscall CWTTLogger::~CWTTLogger(void)"(__imp_??1CWTTLogger@@UAE@XZ)1>Logger.lib(Logger.obj):错误 LNK2001:未解析的外部符号__declspec(dllimport) public: long __thiscall CWTTLogger::FunctionA(unsigned short *,long *)"(__imp_?FunctionA@CWTTLogger@@QAEJPAGPAJ@Z)1>Logger.lib(Logger.obj):错误 LNK2001:未解析的外部符号__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):错误 LNK2001:未解析的外部符号__declspec(dllimport) public:long __cdecl CWTTLogger::FunctionD(unsigned long,long,...)"(__imp_?FunctionD@CWTTLogger@@QAAJKJZZ)1>Logger.lib(Logger.obj):错误 LNK2001:未解析的外部符号__declspec(dllimport) public: long __thiscall CWTTLogger::FunctionE(unsigned short *,long)"(__imp_?FunctionE@CWTTLogger@@QAEJPAGJ@Z)1>C:UsersUser1DocumentsXYZCode64bitaaa.exe:致命错误 LNK1120:7 个未解析的外部

还要加上::

我对设置做了 2 处更改,使我的 AAA.exe 代码从 32 位变为 64 位::1)

2)

当然,代码兼容 32 位和64 位.为了使 32 位 AAA.exe 代码成为 64 位构建,VC2008 中的这 2 个设置更改是否完整?

通过查看另一个stackoverflow链接,我看到项目配置属性->链接器->高级->目标机器默认为未设置"中还有一个设置如果我让目标机器 == "MACHINEx64",我会得到一个不同类型的错误,我之前得到过 ::

<块引用>

"致命错误 LNK1112: 模块机器类型 'X86' 与目标冲突机器类型'x64'"

我真的不清楚是否应该将链接器选项中的目标机器"字段设置为未设置"或MACHINEx64"?

如果是是",我需要弄清楚如何解决问题.

解决方案

从表面上看,您只是将一半的项目更改为 x64,其余的留给 Win32.由于您没有显示项目的依赖项,因此很难猜测这是否有问题……无论如何,要成功编译,您必须将所有依赖项(库)切换到 x64!

I have a VC++ code (built using VS2008), which makes use of some static libraries (*.lib files linked statically during compile time).

For ease of understanding let's refer my EXE code as "AAA.EXE" & refer the lib files as "A.lib", b.lib etc...

Both the AAA.EXE code and static libraries code are built using VS2008.

I see that my "AAA.EXE" is working fine in 32-bit version and showing the below linker errors when AAA.EXE is built in 64-bit mode.

I have of course rebuilt the static libraries in 64-bit mode and provided the lib path in my AAA.EXE like this :: "Project Configuration Properties corresponding to AAA.EXE -> Linker -> General/Input".

This linker error is really bothering me form a long time. Any help is greatly appreciated.

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:UsersUser1DocumentsXYZCode64bitaaa.exe: fatal error LNK1120: 7 unresolved externals

Also to add ::

I have done 2 changes in the settings to make my AAA.exe code 64-bit from 32-bit:: 1)

2)

Ofcourse the code is compatible for both 32-bit & 64-bit. Are these 2 settings changes in VC2008 complete for making the 32-bit AAA.exe code 64-bit build?

By looking at another stackoverflow link I see there is one more settoing in "Project Configuration properties -> Linker-> Advanced-> Target machine is default to "not set" and if I make target machine == "MACHINEx64", I get a different sort of error which I was getting earlier ::

"fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'"

I'm really not having a clarity on if I should be setting the "Target machine" field in linker option as "Not Set" or "MACHINEx64"?

If it's a "YES", I need to figure out how to fix the problem.

解决方案

From the looks of it, you're only changing half of your projects to x64 and leave the rest to Win32. Since you don't show your project's dependencies, its hard to guess if that's a problem or not ... in any case, for compilation to succeed you'll have to switch all of the dependent projects (libs) to x64!

这篇关于未解决的外部符号错误仅发生在 64 位模式而不是 32 位构建中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆