I am trying to implement a DLL into my application, but it passed some time since I've written C++, so I have some troubles here... My class in DLL uses the resource file specific to that project. Here you can see my code:
// ErrorHandler.h (in Resources.dll - an MFC Library)
namespace HandWritten
{
class ErrorHandler
{
private:
unsigned int m_error_id;
string get_error_text();
string get_error_code();
public:
ErrorHandler(unsigned int error_id);
~ErrorHandler();
};
}
I have created a console application, with MFC headers included, that has to test the functionality inside my library. This the main source file of the tester:
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
HMODULE hModule = ::GetModuleHandle(NULL);
if (hModule != NULL)
{
// initialize MFC and print and error on failure
if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
}
}
else
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
nRetCode = 1;
}
new HandWritten::ErrorHandler(30001);
return nRetCode;
}
The error I get from the compiler is here:
error LNK2019: unresolved external symbol "public: __thiscall HandWritten::ErrorHandler::ErrorHandler(unsigned int)" (??0ErrorHandler@HandWritten@@QAE@I@Z) referenced in function _wmain E:\Applications\HandWritten\Tester\Tester.obj Tester
Please help me with this because I will get crazy if it doesn't work...
*EDIT: * The implementation of the class contructor:
namespace HandWritten {
ErrorHandler::ErrorHandler(unsigned int error_id) : m_error_id{error_id}
{
string content(MAKEINTRESOURCEA(error_id));
MessageBoxA(NULL, content.c_str(), "Ok", MB_OK);
}
}
ErrorHandler
– Victor{value}
if I know correctly.. The library compiles, but the tester doesn't – Victor