[LLVMdev] Win32: Crash in DLL created by llvm that calls into the "putchar" function
Daniel Albuschat
d.albuschat at gmail.com
Sun Dec 8 10:02:22 PST 2013
Hey Jeremy,
(putting the discussion back to the list.)
2013/12/8 Jeremy Lakeman <Jeremy.Lakeman at gmail.com>:
> If I run your demo exe it crashes, if I re-link the dll with VS 2010 it
> errors gracefully;
>
> runtime error R6030
> - CRT not initialized
>
> putchar is a c runtime function.
> I'm betting that your exe doesn't initialise the runtime library?
You're right, this is surely the problem then. Thanks a buch for that pointer.
However, after quite much googling, I can't find a way to correctly
initialize the CRT in a DLL created from llvm.
>From what I've learned, the system works as follows:
* The entry point for DLLs in __DllMainCRTStartup at 12.
* The CRT libraries provide an implementation for this function in libcmt.lib.
* That implementation initializes the CRT (afaik using CRT_INIT) and
calls DllMain.
The question that remains is how to dllexport a function that is
defined in a separate library?
Greetings,
Daniel Albuschat
More information about the llvm-dev
mailing list