Re: LNK2019 unresolved external symbol / how to ignore dllimport?
Frederiek wrote:
I'm using MS Visual C++ 2005 (MSVC8.0).
I'm currently also porting to that target and worked around some weird
things concerning linking...
class DBP_EXPORT AAA_SSF
{
public:
virtual ~AAA_SSF() { }
AAA_SSF() { }
};
The point is, I guess, that these members are inline.
I am using the header file to create a program based on the library. So
DBP_EXPORT is defined as __declspec (dllimport). But in case of the
above class, this causes a problem when building. The dllimport
specifier in front of the class name, seems to instruct the compiler to
put the class members that are called from the program, in the object
file as external defined functions.
Yes, even though they are inline, it should import them from the DLL when it
doesn't inline them. Note that it doesn't have to use inlining, that is
still just a suggestion to the compiler.
But they are not defined external, they are defined inside the class
definition itself.
Just one guess: the library is built wrong. The thing is that even if a
function is defined inline, the compiler should still emit and export an
out-of-line definition. I couldn't say how to do it wrong...
When the linker processes the object file, it probably looks for some
library containing the class member definitions, but ofcourse it can't
find such a library, and it reports back a LNK2019 unresolved external
symbol error.
Just to make sure, but you do in fact link with the DLL (or, rather,
it's .lib file), right?
Is there a way to instruct the compiler that it should not indicate the
members as defined external if they are in fact defined in the source
itself, even if the dllimport specifier is used?
You could always write a linker file giving explicit instructions what to
export and how, but that shouldn't be necessary IMHO.
Uli