How to use regular dll?
-
In the dll project, I use export funciton like this: extern "C" __declspec(dllexport) START() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); theApp.Start (); } In the Main project which use the dll, I write this: #pragma comment(lib,"xxxxDll.lib") void START(); ... void CADlg::OnStart() { START(); } When linking ,there is an error: TestCltDlg.obj : error LNK2001: unresolved external symbol "void __cdecl START(void)" (?START@@YAXXZ) Why?
-
In the dll project, I use export funciton like this: extern "C" __declspec(dllexport) START() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); theApp.Start (); } In the Main project which use the dll, I write this: #pragma comment(lib,"xxxxDll.lib") void START(); ... void CADlg::OnStart() { START(); } When linking ,there is an error: TestCltDlg.obj : error LNK2001: unresolved external symbol "void __cdecl START(void)" (?START@@YAXXZ) Why?
In your application, you need to mark the function as __declspec(dllimport):
extern "C" __declspec(dllimport) void START();
BTW, I assume you've mistyped the function at the top and left out thevoid
keyword. Functions with no specified return type implicitly returnint
, notvoid
.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"