0
votes

I have created Regular DLLs Dynamically Linked to MFC. in before build dll in dll project i used add another class. this class provide more method of constructor overloading. Then I build dll successfully after i used this lib and dll file include project and then go to build and get linker error when using constructor overloading class

My Class Name: Object

Error   11  error LNK2001: unresolved external symbol "public: __thiscall AvinashiAMF::Object::~Object(void)" (??1Object@AvinashiAMF@@QAE@XZ)   BuleCappServiceUseDynamicDllDlg.obj

Error   10  error LNK2001: unresolved external symbol "public: __thiscall AvinashiAMF::Object::Object(enum AvinashiAMF::ObjectType,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Object@AvinashiAMF@@QAE@W4ObjectType@1@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)   BuleCappServiceUseDynamicDllDlg.obj

Error   12  fatal error LNK1120: 2 unresolved externals D:\Test Aplications\Visual Studio 2008\Projects\BuleCappServiceUseDynamicDll\Release\BuleCappServiceUseDynamicDll.exe
2

2 Answers

0
votes

You're probably not exporting your class. See here http://msdn.microsoft.com/en-us/library/81h27t8c.aspx

Also, a nice tool to check for this kind of issues is depends.exe, included with Visual Studio, which allows you to check for exported and imported symbols.

0
votes

There are two significantly different dynamic link libraries: implicitly linked and explicitly linked.

In short, implicitly linked is linked at the compile time. You need an import library to link with(.lib), header file with functions prototypes and properly usage of the dllexport and dllexport or use .def file. dllexport/dllexport are easier to use in this case. System takes care of loading libraries (DLLs).

Explicit linking is a runtime linking. You do not need any import library or headers. You need to know what is the function signature. You have to explicitly call LoadLibrary and GetProcAddress to call the function.

To see how to properly create macros for export/import create empty Win32 project select DLL and make sure the Export symbols check box is checked. In the main header file you will see explanation how to use macros for import/export.