Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hello everyone,

i experienced the following very strange behavior/difference in Visual Studio 2003 and 2010:

Two seperate projects will be created in VS2003. One of them is build as a MFC extension DLL (named MFC_Extension_DLL) and the other one is build as a MFC DLL (named MFC_USINGDLL). They will be created in two seperate application instances of Visual Studio 2003.

Inside of the MFC_Extension_DLL, a file called MyClass.h and another one called MyClass.cpp will be created. In those two files, respectively the appropriate declaration of the class and the definitions of the member functions will be written down. Within the Header file, AFX_EXT_CLASS is used to tell the compiler, that the class has to be exported.

Inside of the MFC_USINGDLL, the MyClass.h file will be included directly from inside of the project directory of the MFC_Extension_DLL. Thanks to the AFX_EXT_CLASS macro, the compiler knows at this point it has to import the class here. Now in any method, the MyClass class will be instantiated and one of the public methods will be called.
So far so good, the linker does not work => unresolved external symbol. Everything ok.

Now, in the opened solution of the MFC_USINGDLL, the MFC_Extension_DLL project will be added. Still nothing works.
But now, in the project dependencies of the MFC_USINGDLL, a dependency to the MFC_Extension_DLL will be added.
WTF? The linker runs greatly... and this without any statically linking to the required import library MFC_Extension_DLL.lib!

One last test: I perform exactly the same steps in VS2010. Despite the project dependency, the linker stops because of the unresolved member function.

Please, could somebody explain me this?


Yours sincerely,

Allgaeuer
Posted

 
Share this answer
 
Comments
Albert Holguin 13-Jan-13 8:56am    
Good to know... that's why I always hesitate switching IDEs! :D
I'm not following the story quite 100% but it sounds to me that you have something mixed up in the __declspec(dllimport) and __declspec(dllexport) symbols. Make sure that you have these and the macro symbols using them set up correctly.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900