Click here to Skip to main content
Rate this: bad
good
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,
 
Allgaeuer
Posted 10-Jan-13 0:27am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Comments
Albert Holguin at 13-Jan-13 8:56am
   
Good to know... that's why I always hesitate switching IDEs! :D
Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 Afzaal Ahmad Zeeshan 170
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,777
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2014
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