Unresolved external symbolic error that occurs only in 64-bit mode, and not in 32-bit assembly

I have VC ++ code (built using VS2008) that uses some static libraries (* .lib files statically linked at compile time).

For ease of understanding, we send my EXE code as "AAA.EXE" and refer to the lib files as "A.lib", b.lib, etc.

Both AAA.EXE and static library code are built using VS2008.

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

Of course, I restored the static libraries in 64-bit mode and provided the lib path in my AAA.EXE as follows: "Project configuration properties corresponding to AAA.EXE β†’ Linker β†’ General / Input".

This linker error has really bothered me for a long time. Any help is 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:\Users\User1\Documents\XYZ\Code\64bit\aaa.exe: fatal error LNK1120: 7 unresolved externals 

Also add ::

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

2) 64-bit build for each project in COnfiguration properties page

Of course, the code is compatible for both 32-bit and 64-bit. Are these 2 configuration changes in VC2008 completed to make the 32-bit AAA.exe code a 64-bit build?

Looking at another stackoverflow link, I see that the project settings β†’ Linker-> Advanced-> Target use one more setting: the default value is "not set" and if I create the target machine == "MACHINEx64", I get another error i got before:

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

I really don’t have clarity if I have to set the Target Machine field in the linker option as Not Specified or MACHINEx64?

If it is YES, I need to figure out how to fix the problem.

+4
source share
4 answers

In appearance, you change only half of your projects to x64 and leave the rest to Win32 . Since you are not showing project dependencies, it's hard to guess if this is a problem or not ... anyway, to compile for success you will have to switch all dependent projects (libs) to x64!

+5
source

This fatal error LNK1112 indicates that you are really linking something in 32-bit mode when trying to create a 64-bit executable.

Image 2) shows only some, but not all projects in 64-bit mode. That sounds like a problem!

Perhaps the problem lies in your LIB directory? Usually my projects (VS2010 here) are different:

 Project Properties -> VC++ Directories -> Library Directories 

which points to the lib32 or lib64 depending on the target architecture.

+4
source

I think I understand what the problem is.

AAA.EXE used the static library Logger.lib, which in turn called functions in WTTLog.DLL. And this Microsoft DLL "WTTLog.DLL" is a 32-bit DLL.

That is why it did not work for me in 64-bit AAA.EXE.

So, I found the answer to the question that I raised in this thread, and how to link 64-bit libraries in a 64-bit application. BUt still this leaves me another question,

"Where can I find the 64-bit version of WTTLog.lib and" wttlogger.h "for WTTLog.DLL. For this, I created a new thread, because now the problem is different.

How to get the header file WTTLog.lib and wttlogger.h for the 64-bit version of WTTLog.DLL

+1
source

The old thread, I know, but found that I had to add an "Explicit" export to the DEF file to make it work. There must be a 32-bit implicit append, but 64 was not. Hope this helps someone :)

+1
source

Source: https://habr.com/ru/post/1498904/


All Articles