0
votes

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)
2
What is the provenance of QRFound.dll? It might be that it was built with a different C++ compiler, and in general, exporting C++ interfaces from DLLs is a terrible idea: stick to C interfaces or use COM instead.richard.albury

2 Answers

3
votes

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.

0
votes

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.