none
Migrating VS2008 MFC project to 64bit system having linker errors RRS feed

  • Question

  • 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)

    Thursday, March 22, 2018 3:45 AM

All replies

  • 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.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    • Proposed as answer by Guido Franzke Thursday, March 22, 2018 8:38 AM
    Thursday, March 22, 2018 4:17 AM
  • Thanks Darran Rowe for your reply. Yea, you are right, maybe there are indirect libraries that still linked within an x86 systems. I have to check them for all the DLLs projects to ensure that.
    Thursday, March 22, 2018 5:35 AM
  • Hi slee_59,

    Thank you for posting here.

    If your issue has been resolved, please remember to close your thread by marking useful posts as answer that can be helpful for other person with same issue.

    Best Regards,

    Hart


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 23, 2018 7:05 AM
    Moderator