I'm working on a pet project which dynamically loads several dlls. One of the dll in turn has to be linked to a static libarary but i am getting the following unresolved external symbol errors and i can't figure out why.
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Poco::DateTime::~DateTime(void)" (__imp_??1DateTime@Poco@@QAE@XZ) referenced in function "public: bool __thiscall AISMTPConnection::Process(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Process@AISMTPConnection@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
Got it. You cannot import anything into a library, you can only export.
In the file dynamicLib.cpp
theres a slight change.
1 2 3 4 5 6 7 8 9 10 11
#include "dynamicLib.h"
//#define STDLLIMPORT //this is not required when you are importing into a library.
#include "staticLib.h"
extern"C"
{
DYDECLDIR char* dynamicLibFunc()
{
return staticLibFunc();
}
}
In Windows, a DLL can use stuff defined in another DLL, in which case, it does import it. The user of the DLL doesn't need to know about the library's dependcies.
Unix is different, libraries can be built without resolving the external references. When the hosting application is linked, it must state all dependent libraries.