将VS2008 MFC项目迁移到具有链接器错误的64位系统 [英] Migrating VS2008 MFC project to 64bit system having linker errors

查看:78
本文介绍了将VS2008 MFC项目迁移到具有链接器错误的64位系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MFC项目,它使用VS2008在32位系统中构建和运行良好。但是,由于PC兼容问题,我们已将此项目迁移/移植到64位系统。


该项目由几个Dll和一个调用这些Dll的主项目组成。所有项目都已设置为x64环境。在构建DLL项目时我没有遇到任何问题,但是,在构建主项目时我遇到了很多这些链接器错误。


我曾尝试修改主项目中的stdafx.h文件但仍然是一样的。


任何可以帮助我吗?提前谢谢。





1> Am.obj:错误LNK2001:未解析的外部符号" __ declspec(dllimport) public:class ATL :: CStringT< char,class StrTraitMFC_DLL< char,class ATL :: ChTraitsCRT< char> > > const& __cdecl SpApiDb :: GetModel(long)const" (__imp_?GetModel @ SpApiDb @@ QEBAAEBV?$ CStringT @ DV?$ StrTraitMFC_DLL @ DV?$ ChTraitsCRT @ D @ ATL @@@@@ ATL @@ J @ Z)

1> AuDlg。 obj:错误LNK2001:未解析的外部符号" __ declspec(dllimport)public:class ATL :: CStringT< char,class StrTraitMFC_DLL< char,class ATL :: ChTraitsCRT< char> > > const& __cdecl SpApiDb :: GetModel(long)const" (__imp_?GetModel @ SpApiDb @@ QEBAAEBV?$ CStringT @ DV?$ StrTraitMFC_DLL @ DV?$ ChTraitsCRT @ D @ ATL @@@@@ ATL @@ J @ Z)

1>条形码。 obj:错误LNK2001:未解析的外部符号" __ declspec(dllimport)public:class ATL :: CStringT< char,class StrTraitMFC_DLL< char,class ATL :: ChTraitsCRT< char> > > const& __cdecl SpApiDb :: GetModel(long)const" (__imp_?GetModel @ SpApiDb @@ QEBAAEBV?$ CStringT @ DV?$ StrTraitMFC_DLL @ DV?$ ChTraitsCRT @ D @ ATL @@@@@ ATL @@ J @ Z)

1> BlkEdit。 obj:错误LNK2001:未解析的外部符号" __ declspec(dllimport)public:class ATL :: CStringT< char,class StrTraitMFC_DLL< char,class ATL :: ChTraitsCRT< char> > > const& __cdecl SpApiDb :: GetModel(long)const" (__imp_?GetModel @ SpApiDb @@ QEBAAEBV?$ CStringT @ DV?$ StrTraitMFC_DLL @ DV?$ ChTraitsCRT @ D @ ATL @@@@@ ATL @@ J @ Z)

1> Am。 obj:错误LNK2019:函数"int __cdecl XccdSet(void)"中引用的未解析的外部符号__imp_Xccd_GetStatus (?XccdSet @@ YAHXZ)
$
1> Am.obj:错误LNK2019:未解析的外部符号__imp_Xccd_Init在函数"int __cdecl XccdSet(void)"中引用(?XccdSet @@ YAHXZ)
$
1> Am.obj:错误LNK2019:函数中引用的未解析的外部符号__imp_Xccd_ReadCCDdataMem" void __cdecl grab_imageX(类Halcon :: Hobject *,int)" (?grab_imageX @@ YAXPEAVHobject @ Halcon @@ H @ Z)
$
1> Am.obj:错误LNK2019:未解析的外部符号__imp_Xccd_TriggerShutter在函数中引用"void __cdecl grab_imageX(类Halcon :: Hobject * ,INT)" (?grab_imageX @@ YAXPEAVHobject @ Halcon @@ H @ Z)

1> Am.obj:错误LNK2019:函数中引用的未解析的外部符号__imp_Fx2_CloseDev" void __cdecl ImageClose(void)" (?ImageClose @@ YAXXZ)

解决方案

我知道当你得到很多像这样看似胡言乱语的人时,你认为"这意味着什么"。但这不是标题的问题。这是链接器错误的事实说这是在构建最终的
可执行文件期间发生的问题。这是通过编译器的方式,所以到目前为止所有的头都包含在内而没有问题。


这些错误告诉你的是你的应用程序使用了一些函数存在于DLL中。尝试访问这些函数时,链接器无法在您提供的库(.lib)文件中找到它们。


例如,第一个失败的文件找到的是:

 const CString& SpApiDb :: GetModel(long)const; 

输出使用包含所有模板参数和调用约定的完整声明。


最后几个是缺少函数或全局变量,如Xccd_Init,Xccd_ReadCCDdataMem,Xccd_TriggerShutter和Fx2_CloseDev。


这意味着两件事之一。首先,您没有为已用于x64项目配置的任何额外库添加任何导入库。这很容易做到,因为Visual C ++属性页不一定要设置为
到与Visual Studio本身相同的配置。


其次,你添加了x86导入库作为x64项目的输入。如果要将其构建为目标x64,则需要为项目使用64位库,使用现有的32位库将无法工作。这背后的原因有两个,首先是
,内部命名在32位和64位构建之间是不同的,导入库是32位,并且你不能将32位和64位的东西合并在一起。 / p>


I have a MFC project which is building and running fine in 32 bits system with VS2008. However, we have migrate/port this project to 64 bit system due to PC compatible issue.

The project consists of a few Dlls and a main project that calls those Dlls. All of projects had been set to x64 environment. I face no issues when building the DLL projects, however, I got lots of these linker errors when building the main project.

I had tried to modify the stdafx.h file in the main project but still the same.

Any can help me on this? Thank you in advance.


1>Am.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > const & __cdecl SpApiDb::GetModel(long)const " (__imp_?GetModel@SpApiDb@@QEBAAEBV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@J@Z)
1>AuDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > const & __cdecl SpApiDb::GetModel(long)const " (__imp_?GetModel@SpApiDb@@QEBAAEBV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@J@Z)
1>Barcode.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > const & __cdecl SpApiDb::GetModel(long)const " (__imp_?GetModel@SpApiDb@@QEBAAEBV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@J@Z)
1>BlkEdit.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > const & __cdecl SpApiDb::GetModel(long)const " (__imp_?GetModel@SpApiDb@@QEBAAEBV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@J@Z)
1>Am.obj : error LNK2019: unresolved external symbol __imp_Xccd_GetStatus referenced in function "int __cdecl XccdSet(void)" (?XccdSet@@YAHXZ)
1>Am.obj : error LNK2019: unresolved external symbol __imp_Xccd_Init referenced in function "int __cdecl XccdSet(void)" (?XccdSet@@YAHXZ)
1>Am.obj : error LNK2019: unresolved external symbol __imp_Xccd_ReadCCDdataMem referenced in function "void __cdecl grab_imageX(class Halcon::Hobject *,int)" (?grab_imageX@@YAXPEAVHobject@Halcon@@H@Z)
1>Am.obj : error LNK2019: unresolved external symbol __imp_Xccd_TriggerShutter referenced in function "void __cdecl grab_imageX(class Halcon::Hobject *,int)" (?grab_imageX@@YAXPEAVHobject@Halcon@@H@Z)
1>Am.obj : error LNK2019: unresolved external symbol __imp_Fx2_CloseDev referenced in function "void __cdecl ImageClose(void)" (?ImageClose@@YAXXZ)

解决方案

I know when you get a lot of seemingly gibberish like this, you think "what does this mean". But this is not a problem with headers. The fact that this is a linker error says that this is a problem that occurred during the building of the final executable file. This is way past the compiler, so by this point all of the headers would have been included without issue.

What these errors are telling you is that there are some functions that your application uses that exist in a DLL. When trying to get access to these functions, the linker is unable to find them in the library (.lib) files that you have provided.

For example, the first one that it is failing to find is:

const CString & SpApiDb::GetModel(long) const;

The output uses the full declaration which includes all of the template parameters and the calling convention.

The last few are missing functions or global variables like Xccd_Init, Xccd_ReadCCDdataMem, Xccd_TriggerShutter and Fx2_CloseDev.

This means one of two things. First, you have not added any import libraries for any extra libraries that you have used to the x64 project configuration. This is easy enough to do since the Visual C++ property pages don't necessarily have to be set to the same configuration as Visual Studio itself.

Secondly, you have added the x86 import libraries as input to the x64 project. You need to use 64 bit libraries for your project if you want to build it to target x64, using the existing 32 bit libraries will not work. The reason behind this is two fold, first, the internal naming is different between 32 bit and 64 bit builds, and the import libraries are 32 bit, and you can't merge 32 bit and 64 bit things together.


这篇关于将VS2008 MFC项目迁移到具有链接器错误的64位系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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