digitalmars.D.learn - Talking to non-D libraries
- Richard Heyes <Richard_member pathlink.com> Feb 18 2006
- clayasaurus <clayasaurus gmail.com> Feb 18 2006
- Richard Heyes <richardh phpguru.org> Feb 18 2006
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> Feb 18 2006
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> Feb 18 2006
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> Feb 18 2006
- Richard Heyes <richardh phpguru.org> Feb 18 2006
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> Feb 18 2006
- Chris <central_p hotmail.com> Feb 19 2006
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> Feb 20 2006
- Chris <central_p hotmail.com> Feb 20 2006
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> Feb 20 2006
- Chris <central_p hotmail.com> Feb 20 2006
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> Feb 20 2006
- Cris <central_p hotmail.com> Feb 20 2006
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> Feb 20 2006
- Cris <central_p hotmail.com> Feb 20 2006
- Ivan Senji <ivan.senji_REMOVE_ _THIS__gmail.com> Feb 20 2006
- Chris <central_p hotmail.com> Feb 20 2006
- clayasaurus <clayasaurus gmail.com> Feb 20 2006
- Chris <central_p hotmail.com> Feb 20 2006
Can anyone point me to a laymans guide to how I would talk to a non D library,
for example sqlite.so.
I've managed so far to use (for example) getpid() like so:
extern (C) {
int getpid();
}
But what about other libraries?
Thanks.
Feb 18 2006
http://www.digitalmars.com/d/interfaceToC.html ? Richard Heyes wrote:Can anyone point me to a laymans guide to how I would talk to a non D library, for example sqlite.so. I've managed so far to use (for example) getpid() like so: extern (C) { int getpid(); } But what about other libraries? Thanks.
Feb 18 2006
clayasaurus wrote:http://www.digitalmars.com/d/interfaceToC.html ?
Thanks. Isn't there also a requirement to tell the compiler to link against the external .so? Cheers. -- Richard Heyes
Feb 18 2006
"Richard Heyes" <richardh phpguru.org> wrote in message news:dt7ito$2en4$1 digitaldaemon.com...clayasaurus wrote:http://www.digitalmars.com/d/interfaceToC.html ?
Thanks. Isn't there also a requirement to tell the compiler to link against the external .so?
You can use implib to generate an "import library" for a dynamically linked library. The generated import library can then be linked with your program so the linker will know where to find the functions. I'm pretty sure implib exists in *nix. I'd be very surprised if it didn't.
Feb 18 2006
Jarrett Billingsley wrote:You can use implib to generate an "import library" for a dynamically linked library. The generated import library can then be linked with your program so the linker will know where to find the functions. I'm pretty sure implib exists in *nix. I'd be very surprised if it didn't.
It's normally not needed, you can link with the dynamic lib directly. --anders
Feb 18 2006
"Anders F Björklund" <afb algonet.se> wrote in message news:dt7qtn$2ktg$1 digitaldaemon.com...It's normally not needed, you can link with the dynamic lib directly.
Really! That's news to me :)
Feb 18 2006
Jarrett Billingsley wrote:"Anders F Björklund" <afb algonet.se> wrote in message news:dt7qtn$2ktg$1 digitaldaemon.com...It's normally not needed, you can link with the dynamic lib directly.
Ummm, how? With the C# compiler there's a command line flag to specify the .so/.dll, but there doesn't appear to be such an option with dmd. Cheers. -- Richard Heyes
Feb 18 2006
Richard Heyes wrote:Ummm, how? With the C# compiler there's a command line flag to specify the .so/.dll, but there doesn't appear to be such an option with dmd.
Either with the full library path, or by using the "-L-lfoo" syntax. GDC uses the GCC syntax: -lfoo --anders
Feb 18 2006
Jarrett Billingsley wrote:It's normally not needed, you can link with the dynamic lib directly.
Really! That's news to me :)
A common approach is that you have one "versioned" shared library: libfoo.so.1.2.3 libfoo.1.2.3.dylib And then you have one "developer" library, which is just a symlink: libfoo.so -> libfoo.so.1.2.3 libfoo.dylib -> libfoo.1.2.3.dylib Then you can use "-lfoo" flag to link, it'll pick the current version. Your binary will end up requiring the correct 1.2.3 version at runtime. --anders PS. ".so" are being used in e.g. Linux, and ".dylib" in Darwin/Mac.
Feb 18 2006
I'm trying to use the SDL lib from your site but I get: Not a valid library file. Anders F Björklund wrote:Jarrett Billingsley wrote:It's normally not needed, you can link with the dynamic lib directly.
Really! That's news to me :)
A common approach is that you have one "versioned" shared library: libfoo.so.1.2.3 libfoo.1.2.3.dylib And then you have one "developer" library, which is just a symlink: libfoo.so -> libfoo.so.1.2.3 libfoo.dylib -> libfoo.1.2.3.dylib Then you can use "-lfoo" flag to link, it'll pick the current version. Your binary will end up requiring the correct 1.2.3 version at runtime. --anders PS. ".so" are being used in e.g. Linux, and ".dylib" in Darwin/Mac.
Feb 19 2006
Chris wrote:I'm trying to use the SDL lib from your site but I get: Not a valid library file.
Actually I'm not sure if I put the DMC or the original Win lib there... Murphy's states that whatever it is for, it's probably not yours :-) However, the real deal should be available from http://www.libsdl.org/ --anders
Feb 20 2006
Thanks, I've tried the original .libs too they also cannot be recognized. I cannot understand how to deal with .libs for now. I've tried the version found here: http://shinh.skr.jp/d/porting.html and it works. Then there is a SDL_image.d file but no lib for it and I cannot make it link in any way. I've opened the lib files (but not with a HEX editor) and I saw there is the following difference: the original have this at the beginning of the file: !<arch> / 1100558372 0 1248 The other one and the one I've tried to generate with lib.exe - don't, they have something like: ð I'm reading this: http://www.digitalmars.com/d/interfaceToC.html http://www.digitalmars.com/d/htomodule.html And I still don't understand what to do ;). Regards, ChrisActually I'm not sure if I put the DMC or the original Win lib there... Murphy's states that whatever it is for, it's probably not yours :-) However, the real deal should be available from http://www.libsdl.org/ --anders
Feb 20 2006
Chris wrote:I've tried the original .libs too they also cannot be recognized.
If you want to use them with DMC/DMD, you need to convert them first. There should be a tool to do this for you: ftp://ftp.digitalmars.com/coffimplib.zipI've tried the version found here: http://shinh.skr.jp/d/porting.html and it works. Then there is a SDL_image.d file but no lib for it and I cannot make it link in any way.
You need to convert the original library then, for use with DMC/DMD. It can be found from here: http://www.libsdl.org/projects/SDL_image/I'm reading this: http://www.digitalmars.com/d/interfaceToC.html http://www.digitalmars.com/d/htomodule.html And I still don't understand what to do ;).
That's OK, but please give your OS and D compiler next time... http://www.prowiki.org/wiki4d/wiki.cgi?D__Tutorial/BugReports --anders
Feb 20 2006
That's OK, but please give your OS and D compiler next time... http://www.prowiki.org/wiki4d/wiki.cgi?D__Tutorial/BugReports
Sorry, I usually forget to do it. As I said already: I currently use DMD on Windows. I have also installed Cygwin GDC but it requires the cygwin.dll so I prefer DMD for linux and I'm scared to compiles source files :) at least on Windows, so I haven't tryied to compile MingGW with D support. Later on, I'll try D on Linux but for now I want to start with D as soon as possible. I use Code::Blocks as na IDE and unfortunately I do not have much time to try out things. I see you have converted the OpenGL headers, was it difficult are there any special cases? For OpenGL I use GLEW (http://glew.sourceforge.net/) and I might try to convert it. That's why I'm asking.
Feb 20 2006
Chris wrote:Sorry, I usually forget to do it. As I said already: I currently use DMD on Windows. I have also installed Cygwin GDC but it requires the cygwin.dll so I prefer DMD for linux and I'm scared to compiles source files :) at least on Windows, so I haven't tryied to compile MingGW with D support.
I'm dabbling with GDC under MinGW myself, will package it if I succeedI see you have converted the OpenGL headers, was it difficult are there any special cases?
Not too many, I have a perl script that did most of the translating.For OpenGL I use GLEW (http://glew.sourceforge.net/) and I might try to convert it. That's why I'm asking.
It said "C++" on the box, so it might be somewhat trickier. Try it :-) --anders
Feb 20 2006
I'm dabbling with GDC under MinGW myself, will package it if I succeed
:) If you release MinGW packaged + a working gdb, that'd be great! You might help spreading a good language to the poor old world.I see you have converted the OpenGL headers, was it difficult are there any special cases?
Not too many, I have a perl script that did most of the translating.For OpenGL I use GLEW (http://glew.sourceforge.net/) and I might try to convert it. That's why I'm asking.
It said "C++" on the box, so it might be somewhat trickier. Try it :-)
I think it is C just as OpenGL.h is but it is enormous almost 1Mb of code.I've tried the original .libs too they also cannot be recognized.
If you want to use them with DMC/DMD, you need to convert them first. There should be a tool to do this for you: ftp://ftp.digitalmars.com/coffimplib.zip
Thank you! Now I've managed to link SDL_image.lib but now I have this error: Error 42: Symbol Undefined __init_6events9SDL_Event I see you have discussed it in another thread with another Chris (I'll change my name to Cris now). I've downloaded the packaged 1.2.8 version, because I don't usually use cvs but it seems I have to download a client now.
Feb 20 2006
Cris wrote:Error 42: Symbol Undefined __init_6events9SDL_Event I see you have discussed it in another thread with another Chris (I'll change my name to Cris now).
That's from the D wrapper. Just include sdl/*.d as well. --anders
Feb 20 2006
Anders F Björklund wrote:Cris wrote:Error 42: Symbol Undefined __init_6events9SDL_Event I see you have discussed it in another thread with another Chris (I'll change my name to Cris now).
That's from the D wrapper. Just include sdl/*.d as well. --anders
Hmmm, how do you mean I should include sdl/*.d as well? (Note: I use Code::Blocks IDE to compile and I don't know what parameters it passes to DMD.exe) I've already have "import SDL" or you mean I have to import all .d files in the project? I have to try that.
Feb 20 2006
Chris wrote:That's OK, but please give your OS and D compiler next time... http://www.prowiki.org/wiki4d/wiki.cgi?D__Tutorial/BugReports
Sorry, I usually forget to do it. As I said already: I currently use DMD on Windows. I have also installed Cygwin GDC but it requires the cygwin.dll so I prefer DMD for linux and I'm scared to compiles source files :) at least on Windows, so I haven't tryied to compile MingGW with D support. Later on, I'll try D on Linux but for now I want to start with D as soon as possible. I use Code::Blocks as na IDE and unfortunately I do not have much time to try out things. I see you have converted the OpenGL headers, was it difficult are there any special cases? For OpenGL I use GLEW (http://glew.sourceforge.net/) and I might try to convert it. That's why I'm asking
Don't know if it helps but http://glfw.sourceforge.net/ has import files for D.
Feb 20 2006
Don't know if it helps but http://glfw.sourceforge.net/ has import files for D.
Yes it's interesting but it doesn't seem to support OpenGL 2.0
Feb 20 2006
Have you tried the derelict project on dsource.org? It is good for both linux and windows, it will load .dll and .so files at runtime so you don't have to mess with .lib formats. Chris wrote:Thanks, I've tried the original .libs too they also cannot be recognized. I cannot understand how to deal with .libs for now. I've tried the version found here: http://shinh.skr.jp/d/porting.html and it works. Then there is a SDL_image.d file but no lib for it and I cannot make it link in any way. I've opened the lib files (but not with a HEX editor) and I saw there is the following difference: the original have this at the beginning of the file: !<arch> / 1100558372 0 1248 The other one and the one I've tried to generate with lib.exe - don't, they have something like: ð I'm reading this: http://www.digitalmars.com/d/interfaceToC.html http://www.digitalmars.com/d/htomodule.html And I still don't understand what to do ;). Regards, ChrisActually I'm not sure if I put the DMC or the original Win lib there... Murphy's states that whatever it is for, it's probably not yours :-) However, the real deal should be available from http://www.libsdl.org/ --anders
Feb 20 2006
Sorry I forgot this: Are lib files dependent of the platform? (I use Windows for now, later also I'll be try Linux too).
Feb 20 2006
Chris wrote:Are lib files dependent of the platform? (I use Windows for now, later also I'll be try Linux too).
Yes, they depend on both the platform and the compiler... Fortunately it is easier on Linux, since you can link to the dynamic library directly and almost everyone uses GCC. --anders
Feb 20 2006









=?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> 