Linking to MSVCRT
John Reimer
terminal.node at gmail.com
Thu Jan 25 10:47:19 PST 2007
On Wed, 24 Jan 2007 10:19:46 -0500, Robin Allen wrote:
> The Windows C runtime (MSVCRT.DLL) defines some functions, namely _open_osfhandle and _fdopen, that I need to use in my D program.
>
> However, D doesn't seem to link to the necessary libs by default; the linker says:
>
> Symbol Undefined __open_osfhandle at 8
> Symbol Undefined __fdopen at 8
>
> I've tried manually linking to snn.lib, which my text editor tells me *does* include both these symbols, but to no avail. I've also tried generating my own import library for MSVCRT using implib.exe, but this just results in the additional error:
>
> Previous Definition Different: _errno
>
> Is there any way I can use these functions from D?
You can almost always load these functions up at runtime using
LoadLibraryA/GetProcAddress calls. Doing it that way usually allows you to
get around all those annoying import lib linking problems. It may not be
pretty, but at least it guarantees your D program access to almost any C
based dll no matter what compiler was used to make it.
-JJR
More information about the Digitalmars-d-learn
mailing list