Click here to Skip to main content
13,142,622 members (53,635 online)
Rate this:
Please Sign up or sign in to 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,

Posted 9-Jan-13 23:27pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Albert Holguin 13-Jan-13 8:56am
Good to know... that's why I always hesitate switching IDEs! :D
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100