digitalmars.D.learn - Linking to MSVCRT
- Robin Allen (7/7) Jan 24 2007 The Windows C runtime (MSVCRT.DLL) defines some functions, namely _open_...
- Lionello Lunesu (7/14) Jan 24 2007 By the looks of it, those two seem to be simple wrappers for Win32's
- Robin Allen (3/25) Jan 24 2007 They convert from Win32 HANDLEs to FILE*s and back; I was trying to use ...
- John Reimer (7/19) Jan 25 2007 You can almost always load these functions up at runtime using
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 8 Symbol Undefined __fdopen 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?
Jan 24 2007
"Robin Allen" <r.a3 ntlworld.com> wrote in message news:ep7tei$26c3$1 digitaldaemon.com...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 8 Symbol Undefined __fdopen 8 Is there any way I can use these functions from D?By the looks of it, those two seem to be simple wrappers for Win32's CreateFile function. You could simply call CreateFile yourself. If you have Visual Studio installed, you can peek at their source too, and just do whatever those functions do in D. L.
Jan 24 2007
Lionello Lunesu Wrote:"Robin Allen" <r.a3 ntlworld.com> wrote in message news:ep7tei$26c3$1 digitaldaemon.com...They convert from Win32 HANDLEs to FILE*s and back; I was trying to use them to redirect stdout to a console window. I'm just using WriteFile to write the strings instead of printf now, and that works just as well.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 8 Symbol Undefined __fdopen 8 Is there any way I can use these functions from D?By the looks of it, those two seem to be simple wrappers for Win32's CreateFile function. You could simply call CreateFile yourself. If you have Visual Studio installed, you can peek at their source too, and just do whatever those functions do in D. L.
Jan 24 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 8 Symbol Undefined __fdopen 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
Jan 25 2007