Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Linker Error (LNK2001: unresolved external symbol DllCanUnloadNow,DllGetClassObject,DllRegisterServer,DllUnregisterServer) with IntelC++ Compiler, no errors with MS VC++ Compiler

komal_dutta
Beginner
2,649 Views
Hi,

I used the latest version of Intel C++ Compiler 11.0.072, and the several Linker Errors that i got with version 10 are not seen anymore. Yipeee!!! But I am still getitng the following Linker Errors, even though this solution compiles fine with MS C++ Compiler,

xilink: executing 'link'
BuildManager.def : error LNK2001: unresolved external symbol DllCanUnloadNow
BuildManager.def : error LNK2001: unresolved external symbol DllGetClassObject
BuildManager.def : error LNK2001: unresolved external symbol DllRegisterServer
BuildManager.def : error LNK2001: unresolved external symbol DllUnregisterServer


Why are these errors coming? Am i missing something here?

Regards,
Komal Dutta
0 Kudos
7 Replies
JenniferJ
Moderator
2,649 Views
Quoting - komal_dutta
BuildManager.def : error LNK2001: unresolved external symbol DllCanUnloadNow
So is the .cpp file containing "DllCanUnloadNow()" part of the project? Make sure it's not skiped in the build.

If all is ok, add following in front of the function:

__declspec( dllexport )
0 Kudos
komal_dutta
Beginner
2,649 Views
Hi Jennifer,

I already have "__declspec(dllexport)" added in the function definition. I have the following in my cpp file:
STDAPI DllCanUnloadNow(void)

where STDAPI defined as extern "C" HRESULT __stdcall in winnt.h.

Regards,
Komal
0 Kudos
komal_dutta
Beginner
2,649 Views
Hi,

I have found the reason why I was getting these errors.
The projects where I got these errors were "ATL Project" DLLs with "Allow merging of proxy/stub code" Enabled (during creation of the projects).

The vcproj files of these projects contains the setting:
WholeProgramOptimization="1"
When this is removed from the vcproj file, the project compiles fine with Intel C++ Compiler, without any errors.

Thanks & Regards,
Komal Dutta

P.S.: I have observed an issue with Intel C++ Compiler. When I make some change to the vcproj file and build it with Intel C++ Compiler, it gives errors. When I close and open the project, and build again; IT BUILDS FINE! Any clue why this is so?

0 Kudos
JenniferJ
Moderator
2,649 Views
But the Whole Program Optimization could bring some performance for you.
Those functions are defined by MSVC, so function declarations can not be changed.

I'll create feature request to see if those functions can be handled differently.

Thanks,
Jennifer

0 Kudos
komal_dutta
Beginner
2,649 Views
Hi Jennfer,

Performance is the key reason why we used Intel C++ Compiler.
Please update this forum if you find a way to keep "Whole Program Optimization" on, while building ATL projects.

Thanks & Regards,
Komal Dutta

But the Whole Program Optimization could bring some performance for you.
Those functions are defined by MSVC, so function declarations can not be changed.

I'll create feature request to see if those functions can be handled differently.

Thanks,
Jennifer


0 Kudos
JenniferJ
Moderator
2,649 Views
Hello all,
Good news.
This issue is fixed in our 1st 11.1 update and as well as the Intel Parallel Composer 1st update.

To ensure you're using the 1st update, please log on to Intel Registration & Download center - https://registrationcenter.intel.com/RegCenter/Register.aspx
You may also get the latest version by going to our eval page - http://software.intel.com/en-us/intel-compilers/ (click Evaluate).

Thank you !
Jennifer
0 Kudos
Nikhil_P_
Beginner
2,649 Views

Hi

I have same problem with my code error LNK2001: unresolved external symbol DllCanUnloadNow

But i found solution 

In the same project properties dialogbox, click on c/c++ go to Preprocessor. Then go to preprocessor definitions edit box. add last line REGISTER_PROXY_DLL 

Press OK

Work it..

0 Kudos
Reply