Share via


error LNK2019: unresolved external symbol __declspec(dllimport) in C++ on VS2008

Question

Monday, September 1, 2014 12:41 PM

Hi everybody,

I start a new project in C++ by using Visual Studio 2008. I have added libs and ".h" in my project. But when I try to call functions of these libraries, I obtain the following error:

error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned long __cdecl ias::IASListReadersW(void *,wchar_t *,unsigned long *)"

I have already added paths of my libraries and headers : VC++ Directories ("Tools -> Options -> Projects and Solutions -> VC++ Directories)

In Project properties, "Configuration properties -> C/C++ -> General -> Additional Include Directories", I have put my correct directories.

In "Configuration properties -> Linker -> General -> Additional Library Directories", I have added the path of my libraries.

In "Configuration properties -> C/C++ -> Input -> Additional Dependancies", I have added my Lib files.

I think that I have forgotten something, but what?

Have you got an idea?

Best regards

All replies (6)

Tuesday, September 2, 2014 4:56 AM âś…Answered | 1 vote

I suggest checking the .lib file for exported functions using a tool like DUMPBIN. Is IASListReadersW present? Or maybe the library is not for Unicode builds, therefore try changing the Character Set option to Multi-Byte.


Monday, September 1, 2014 6:58 PM

This is a tough one, because the problem could be one of a few things.

The function given is a function exported from a DLL. Either as a static class member or from a namespace. The reasons why it isn't being found could due to compiler settings, header file issues or the DLL was built with a previous version of VC++ and the name mangling scheme has changed. (This did happen between VC6 and VC7). Or, you are still missing a library for a DLL.

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.


Tuesday, September 2, 2014 4:51 AM

In "Configuration properties -> C/C++ -> Input -> Additional Dependancies", I have added my Lib files.

No such property. I think you meant:

In "Configuration properties -> Linker -> Input -> Additional Dependencies"

  • Wayne

Tuesday, September 2, 2014 5:09 AM

error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned long __cdecl ias::IASListReadersW(void *,wchar_t *,unsigned long *)"

So what is ias::IASListReaders ? Since you didn't get any compile errors (apparently), the
calls you're making in your code must match signatures in the library header(s).

This particular function appears to have wide-character vs. "narrow" character versions,
and you appear to be building with Unicode enabled. This is deduced from the signature
in the error message:

ias::IASListReadersW

The trailing W suggests a wide-char call, assuming the library is following the convention
used in the Win API/SDK. Also the second argument is a pointer to a wide character:

wchar_t *

Since the library header apparently supports this signature, one may assume that the associated
library (import lib) does as well.

  • Wayne

Tuesday, September 2, 2014 7:13 AM

Thank you very much. I try to modify the Character Set option and its work very well!


Tuesday, September 2, 2014 11:26 AM

I try to modify the Character Set option and its work very well!

Glad to hear that you got it working by changing the character set. However, that doesn't
explain why you got a link error but no compile errors. Assuming that you didn't change the
library header - or define your own function prototype - there must be a Unicode version in
the header, as I explained in my earlier post. That suggests you may have mismatched the
header and lib files - or the library provider included Unicode support in the header but
never actually implemented it in the lib/dll.

  • Wayne