HELP. . DLLs?????
-
Hello, I am trying to make my first dll. But I cant get it to work. The linker keeps saying it cant find what it needs. MyTestApp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall CMyTestClass::~CMyTestClass(void)" (__imp_??1CMyTestClass@@UAE@XZ) MyTestAppDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall CMyTestClass::~CMyTestClass(void)" (__imp_??1CMyTestClass@@UAE@XZ) MyTestAppDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall CMyTestClass::CMyTestClass(void)" (__imp_??0CMyTestClass@@QAE@XZ) Debug/MyTestApp.exe : fatal error LNK1120: 2 unresolved externals The DLL i created with the AppWizard (MFC DLL) as an extension dll. The only change I made to the whole thing was I add a class (using the class wizard) as CMyTestClass. It Has one Memebr variable and the empty constructor and deconstructors the class wizard creates. I create an .h file to include for my app. The app is just a generic Dlg app made with AppWizard. It include the .h file for the lib. The .h file conatins the class declaration as such: class AFX_CLASS_IMPORT CMyTestClass { public: CMyTestClass(); virtual ~CMyTestClass(); int m_Shit; }; I moved the dll and .lib files to the Applications project directory so it could find them. What am I doing wrong?? PLease help.
-
Hello, I am trying to make my first dll. But I cant get it to work. The linker keeps saying it cant find what it needs. MyTestApp.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall CMyTestClass::~CMyTestClass(void)" (__imp_??1CMyTestClass@@UAE@XZ) MyTestAppDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall CMyTestClass::~CMyTestClass(void)" (__imp_??1CMyTestClass@@UAE@XZ) MyTestAppDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall CMyTestClass::CMyTestClass(void)" (__imp_??0CMyTestClass@@QAE@XZ) Debug/MyTestApp.exe : fatal error LNK1120: 2 unresolved externals The DLL i created with the AppWizard (MFC DLL) as an extension dll. The only change I made to the whole thing was I add a class (using the class wizard) as CMyTestClass. It Has one Memebr variable and the empty constructor and deconstructors the class wizard creates. I create an .h file to include for my app. The app is just a generic Dlg app made with AppWizard. It include the .h file for the lib. The .h file conatins the class declaration as such: class AFX_CLASS_IMPORT CMyTestClass { public: CMyTestClass(); virtual ~CMyTestClass(); int m_Shit; }; I moved the dll and .lib files to the Applications project directory so it could find them. What am I doing wrong?? PLease help.
Hi Use Win32 Dynamic-Link Library wizard with option "a dll that exports some symbols" it makes some defines for you like these: #ifdef MY_EXPORTS #define MY_API __declspec(dllexport) #else #define MY_API __declspec(dllimport) #endif modify them a little: #ifdef MY_EXPORTS #define MY_API __declspec(dllexport) #elif defined(_STATIC_MY_LIB_) #define MY_API #else #define MY_API __declspec(dllimport) #endif and use MY_API before your classes: class MY_API CMyTestClass {}; now your should define in dll-project (wizard made it for you) MY_EXPORTS don't define any (MY_EXPORTS|_STATIC_MY_LIB_) in projects that use your dll you can make lib-project using same source files just define _STATIC_MY_LIB_ in project settings. ZMike.