简体   繁体   中英

Need help resolving linker error LNK2001 visual studio 2010

I'm having a problem with a pesky linker error and would appreciate tips to find a resolution.

The way I understand the error, the linker is having trouble finding the implementation for the function named 'read' in class 'BFStream'. The code includes a header for the class BFStream. There is an import library QRFound.lib which receives exported functions from QRFound.dll. The dll and the lib are both in the lib directory on the file system. The lib directory is provided in the project properties in two locations: VC++ Directories->Library Directories and Linker->Additional Library Directories. The QRFound.lib is specified in Linker->Input->Additional Dependencies and is first in the list.

I know that QRFound.dll contains the implementation for BFStream::read because I used dependency walker to view it. But the C++ decorations are slightly different from the linker error which has me suspicious: ?read@BFStream@@QAE_NPADH@Z

The linker error is:

1>     Creating library C:\MyProj\Debug\MyDisplay.lib and object C:\MyProj\Debug\MyDisplay.exp
1>MyCmdReceiver.obj : error LNK2001: unresolved external symbol "public: bool __thiscall BFStream::read(char *,__int64)" (?read@BFStream@@QAE_NPAD_J@Z)

Running the undname.exe utility on your symbol produces:

Undecoration of :- "?read@BFStream@@QAE_NPADH@Z"
is :- "public: bool __thiscall BFStream::read(char *,int)"

So, yes, clearly a mismatch on the last argument, __int64 doesn't match int . You didn't post the actual declaration of the method so I can't come up with a decent guess how this mismatch occurred. I suspect it is some kind of macro soup problem.

I suspect you're calling a DLL built with a different compiler.

If you have the source to the DLL, build it with your current compiler: the name mangling will be consistent and you should be able to resolve the issue.

If you don't have the source to the DLL, see if it has a COM interface.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM