digitalmars.D.learn - Talking to non-D libraries
- Richard Heyes (8/8) Feb 18 2006 Can anyone point me to a laymans guide to how I would talk to a non D li...
- clayasaurus (2/16) Feb 18 2006
- Richard Heyes (6/7) Feb 18 2006 Thanks. Isn't there also a requirement to tell the compiler to link
- Jarrett Billingsley (6/10) Feb 18 2006 You can use implib to generate an "import library" for a dynamically lin...
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (3/7) Feb 18 2006 It's normally not needed, you can link with the dynamic lib directly.
- Jarrett Billingsley (3/4) Feb 18 2006 Really! That's news to me :)
- Richard Heyes (6/10) Feb 18 2006 Ummm, how? With the C# compiler there's a command line flag to specify
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (4/6) Feb 18 2006 Either with the full library path, or by using the "-L-lfoo" syntax.
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (11/14) Feb 18 2006 A common approach is that you have one "versioned" shared library:
- Chris (3/26) Feb 19 2006 I'm trying to use the SDL lib from your site but I get: Not a valid
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (5/7) Feb 20 2006 Actually I'm not sure if I put the DMC or the original Win lib there...
- Chris (20/26) Feb 20 2006 Thanks,
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (9/18) Feb 20 2006 If you want to use them with DMC/DMD, you need to convert them first.
- Chris (12/14) Feb 20 2006 Sorry, I usually forget to do it. As I said already: I currently use DMD...
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (5/14) Feb 20 2006 Not too many, I have a perl script that did most of the translating.
- Cris (10/25) Feb 20 2006 I think it is C just as OpenGL.h is but it is enormous almost 1Mb of cod...
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (3/7) Feb 20 2006 That's from the D wrapper. Just include sdl/*.d as well.
- Cris (6/15) Feb 20 2006 Hmmm, how do you mean I should include sdl/*.d as well? (Note: I use
- Ivan Senji (3/23) Feb 20 2006 Don't know if it helps but http://glfw.sourceforge.net/ has import files...
- Chris (1/3) Feb 20 2006 Yes it's interesting but it doesn't seem to support OpenGL 2.0
- clayasaurus (4/42) Feb 20 2006 Have you tried the derelict project on dsource.org? It is good for both
- Chris (3/3) Feb 20 2006 Sorry I forgot this:
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (5/7) Feb 20 2006 Yes, they depend on both the platform and the compiler...
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: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.http://www.digitalmars.com/d/interfaceToC.html ?Thanks. Isn't there also a requirement to tell the compiler to link against the external .so?
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...the .so/.dll, but there doesn't appear to be such an option with dmd. Cheers. -- Richard HeyesIt's normally not needed, you can link with the dynamic lib directly.
Feb 18 2006
Richard Heyes wrote: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: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.It's normally not needed, you can link with the dynamic lib directly.Really! That's news to me :)
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: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.It's normally not needed, you can link with the dynamic lib directly.Really! That's news to me :)
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/BugReportsSorry, 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 think it is C just as OpenGL.h is but it is enormous almost 1Mb of code.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 :-)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.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
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: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.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
Chris wrote:Don't know if it helps but http://glfw.sourceforge.net/ has import files for D.That's OK, but please give your OS and D compiler next time... http://www.prowiki.org/wiki4d/wiki.cgi?D__Tutorial/BugReportsSorry, 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
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