Benutzer mit den meisten Antworten
link error 2019, symbol unresolved - VC9.0

Frage
-
I want to compile a DLL. The compile process works fine. The linker is complaining about an unresolved symbol _CRT_INIT(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved), which is necessary, because my DllEntryPoint is not DllMain(). I suppose an INCLUDE is missing, but which one and where should I include it? Notice that the entrypoint has been specified in the project properties.
In the meanwhile I have solved my problem by using DllMain() as entry point and commenting out all references to _CRT_INIT(..), but I am interested to know why my first attempt has failed.
Thanks for your time
Alain - Stuttgart
Antworten
-
Warum verwendest Du DllEntryPoint?
Verwende einfach DllMain! So ist das für DLLs vorgesehen.
Martin Richter -- MVP for VC++ [Germany] -- http://blog.m-ri.de- Als Antwort markiert Martin RichterModerator Montag, 30. November 2009 12:11
Alle Antworten
-
This is a German forum.
You need always a DllMain. Even this entry point provided from you isn't the true entrypoint. The Linker sets it to an internal Routine in the CRT (C-Runtime) that performs all needed initialization for the CRT. After this is done, DllMain is called.
So it seams that you are doing some strange hacks to this DLL.
Creating a plain DLL just from scratch with the Wizard should not cause such problems you are reporting.
Martin Richter -- MVP for VC++ [Germany] -- http://blog.m-ri.de -
danke für die Antwort, Martin.
Ich schreibe userspezifische Funktionen für ein wissenschaftliches Programm (Mathcad) und habe mich am Beispiel des Herstellers gehalten, leider ohne Erfolg wie oben berichtet. Die Suche auf MSDN hat mich zu den oben beschriebenen Änderungen bewogen, die ja auch letztendlich zum Erfolg geführt haben.
Ich habe nachfolgend das von Mathcad angeführte Beispielprogramm beigefügt, wobei ich die Definition der spezifischen Objekte wie CreateUserErrorMessageTable() und CreateUserFunction hier weggelassen habe
BOOL WINAPI _CRT_INIT(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved);
//
BOOL WINAPI DllEntryPoint (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
{switch (dwReason)
{
case DLL_PROCESS_ATTACH:
//
// DLL is attaching to the address space of
// the current process.
//
if (!_CRT_INIT(hDLL, dwReason, lpReserved)) return FALSE;
// register the error message table
// Note, that if your function never returns
// an error -- you do not need to
// register an error message table
if ( CreateUserErrorMessageTable(hDLL, NUMBER_OF_ERRORS, myErrorMessageTable ) )
// and if the errors register OK
// go ahead and
// register user function
CreateUserFunction( hDLL, &multiply );
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
if (!_CRT_INIT(hDLL, dwReason, lpReserved)) return FALSE;
break;
}
return TRUE;
} -
Warum verwendest Du DllEntryPoint?
Verwende einfach DllMain! So ist das für DLLs vorgesehen.
Martin Richter -- MVP for VC++ [Germany] -- http://blog.m-ri.de- Als Antwort markiert Martin RichterModerator Montag, 30. November 2009 12:11
-
das tue ich ja jetzt und es läuft ja, nachdem ich auch alle Aufrufe _CRT_INIT(..) auskommentiert habe.
Den Code den ich hier gepostet habe ist der Beispielcode von Mathcad. Er wird bereits seit mindestens 8 Jahren verwendet (so weit liegt meine erste version dieses Programms zurück). Ich kann mir nicht vorstellen dass er nicht funktionieren soll und wollte verstehen warum es so ist.
Mein Problem ist jedenfalls gelöst. -
Nachtrag:
Dieser Beispielcode basiert auf nicht dokumentierten Funktionen und Annahmen über die CRT.
Insofern muss man sich nicht wundern, dass es evtl. nicht geht, wenn der Code 8 Jahre alt ist und das VS, das man verwendet brandneu.
Martin Richter -- MVP for VC++ [Germany] -- http://blog.m-ri.de