digitalmars.D.learn - xfbuild, optlink and pragma(lib)
- Mafi (28/28) Jul 30 2010 Hi,
- Mafi (6/6) Aug 01 2010 Ok,
- Mike Parker (13/22) Aug 01 2010 libSDL.dll.a is a MingW- or Cygwin-compiled link library. That's not
- Mafi (8/20) Aug 01 2010 The tool sounds cool but it seems that I have to buy it, so that's no
- div0 (5/27) Aug 01 2010 Just use Derelict and save yourself a world of grief.
- Mike Parker (3/11) Aug 01 2010 I've converted it for you. You can download it here:
- Mafi (4/15) Aug 02 2010 Thank you, but the download is corrupt for me. It's <1kb and most of it
- Trass3r (3/7) Aug 02 2010 Yeah, it's a pity that such an important tool for D development on Windo...
Hi, I wanted to create an simple wrapper around SDL. After my simple first steps, I wanted to create a simple application using my wrapper. That's it: /////// module test; import std.stdio; import mysdl.system; //pragma(lib,r"Path\to\SDL\lib\libSDLmain.a"); pragma(lib,r"Path\to\SDL\lib\libSDL.dll.a"); void main() { initAll(); //Init all SDL-subsystems } //////// I tried to compile it using xfbuild test.d +full +xstd +xcore -debug -I.. +v +o=test (-I.. -> there is mysdl) That doesn't work! It doesn't create any executable but there's no error. Because xfbuild -v doesn't show the linker-command either I tried to reproduce it myself. It seems that optlink is the problem because it does nothing but shows no errormessages. When I comment out the pragma(lib) optlink fails (correctly) and xfbuild crashes (:-(). Then I call optlink myself with libsdl.dll.a and it creates a corrupt exe without errormessages. Please help me. It seems that there are bugs over bugs. I don't konw what to do. I use Windows 7, dmd (2.047), xfbuild with cmd/powershell. PS: I know there's Derelict but wanted to create this myself as a task for learning D.
Jul 30 2010
Ok, OPTLINK is the problem. Without linking SDL, it complains about missing symbol (good) and creates a corrupt executable (so-so). With linking SDL in any way (explicitly or with pragma(lib)) it shows no errormessage (really bad) and does not create any executable (bad). Should I fill a bug report or am I doing something wrong?
Aug 01 2010
Mafi wrote:When I comment out the pragma(lib) optlink fails (correctly) and xfbuild crashes (:-(). Then I call optlink myself with libsdl.dll.a and it creates a corrupt exe without errormessages. Please help me. It seems that there are bugs over bugs. I don't konw what to do. I use Windows 7, dmd (2.047), xfbuild with cmd/powershell.libSDL.dll.a is a MingW- or Cygwin-compiled link library. That's not going to work on Windows with DMD and may very likely be the source of your problem. If you want to link with a DLL link lib, then you need to get the tool coff2omf[1] (part of the Extended Utilities Package[2]) run it on SDL.lib (I suppose it might work on SDL.dll.a), and link with the resulting converted file. Either that or compile SDL with DMC. Alternatively, you could modify your binding to load SDL dynamically like Derelict does. Then you don't need to fool around with any link libs. But, you do need a fair amount of implementation code to load the function symbols from the DLL. [1] http://www.digitalmars.com/ctg/coff2omf.html [2] http://www.digitalmars.com/download/freecompiler.html
Aug 01 2010
libSDL.dll.a is a MingW- or Cygwin-compiled link library. That's not going to work on Windows with DMD and may very likely be the source of your problem. If you want to link with a DLL link lib, then you need to get the tool coff2omf[1] (part of the Extended Utilities Package[2]) run it on SDL.lib (I suppose it might work on SDL.dll.a), and link with the resulting converted file. Either that or compile SDL with DMC. Alternatively, you could modify your binding to load SDL dynamically like Derelict does. Then you don't need to fool around with any link libs. But, you do need a fair amount of implementation code to load the function symbols from the DLL. [1] http://www.digitalmars.com/ctg/coff2omf.html [2] http://www.digitalmars.com/download/freecompiler.htmlThe tool sounds cool but it seems that I have to buy it, so that's no option for me. So I tried to compile SDL myself. I have to say I'm to stupid for it. I tried to do the same thing as the makefile in powershell. After I hacked together some solution that worked dmc complained about missing Gl.h. It isn't there. So I added some MinGW to the include-path and then I get a bunch of errors in SDL without linenumbers. And anyways I am trying to compile it without MinGW, aren't I. Please, help me!
Aug 01 2010
On 01/08/2010 16:22, Mafi wrote:Just use Derelict and save yourself a world of grief. http://dsource.org/projects/derelict Compiling C libs with dmc is easy if you are an experenced C developer, but it's a nightmare if you aren't.libSDL.dll.a is a MingW- or Cygwin-compiled link library. That's not going to work on Windows with DMD and may very likely be the source of your problem. If you want to link with a DLL link lib, then you need to get the tool coff2omf[1] (part of the Extended Utilities Package[2]) run it on SDL.lib (I suppose it might work on SDL.dll.a), and link with the resulting converted file. Either that or compile SDL with DMC. Alternatively, you could modify your binding to load SDL dynamically like Derelict does. Then you don't need to fool around with any link libs. But, you do need a fair amount of implementation code to load the function symbols from the DLL. [1] http://www.digitalmars.com/ctg/coff2omf.html [2] http://www.digitalmars.com/download/freecompiler.htmlThe tool sounds cool but it seems that I have to buy it, so that's no option for me. So I tried to compile SDL myself. I have to say I'm to stupid for it. I tried to do the same thing as the makefile in powershell. After I hacked together some solution that worked dmc complained about missing Gl.h. It isn't there. So I added some MinGW to the include-path and then I get a bunch of errors in SDL without linenumbers. And anyways I am trying to compile it without MinGW, aren't I. Please, help me!
Aug 01 2010
Mafi wrote:The tool sounds cool but it seems that I have to buy it, so that's no option for me. So I tried to compile SDL myself. I have to say I'm to stupid for it. I tried to do the same thing as the makefile in powershell. After I hacked together some solution that worked dmc complained about missing Gl.h. It isn't there. So I added some MinGW to the include-path and then I get a bunch of errors in SDL without linenumbers. And anyways I am trying to compile it without MinGW, aren't I. Please, help me!I've converted it for you. You can download it here: http://aldacron.net/downloads/sdl.lib
Aug 01 2010
Am 02.08.2010 06:16, schrieb Mike Parker:Mafi wrote:Thank you, but the download is corrupt for me. It's <1kb and most of it is '\0'. I downloaded objconv so I should be able to do it myself. MafiThe tool sounds cool but it seems that I have to buy it, so that's no option for me. So I tried to compile SDL myself. I have to say I'm to stupid for it. I tried to do the same thing as the makefile in powershell. After I hacked together some solution that worked dmc complained about missing Gl.h. It isn't there. So I added some MinGW to the include-path and then I get a bunch of errors in SDL without linenumbers. And anyways I am trying to compile it without MinGW, aren't I. Please, help me!I've converted it for you. You can download it here: http://aldacron.net/downloads/sdl.lib
Aug 02 2010
Yeah, it's a pity that such an important tool for D development on Windoze isn't free. You may try objconv though: http://www.agner.org/optimize/?e=0,24#objconv[1] http://www.digitalmars.com/ctg/coff2omf.html [2] http://www.digitalmars.com/download/freecompiler.htmlThe tool sounds cool but it seems that I have to buy it, so that's no option for me.
Aug 02 2010
Am 02.08.2010 16:19, schrieb Trass3r:Thanks, it's a great utility. Converting and dumping works fine. My Program compiles now but a get "object.Error: Access Violation" when I run it. Factored out it's the call to SDL_Init(). Is it because of the conversion (COFF -> ELF -> OMF; COFF -> OMF wasn't possible) or because of my wrong prototype export extern(C) { int SDL_Init(Uint32 flags); } BTW what does a Acces Violation mean? MafiYeah, it's a pity that such an important tool for D development on Windoze isn't free. You may try objconv though: http://www.agner.org/optimize/?e=0,24#objconv[1] http://www.digitalmars.com/ctg/coff2omf.html [2] http://www.digitalmars.com/download/freecompiler.htmlThe tool sounds cool but it seems that I have to buy it, so that's no option for me.
Aug 03 2010
run it. Factored out it's the call to SDL_Init(). Is it because of the conversion (COFF -> ELF -> OMF; COFF -> OMF wasn't possible) or because of my wrong prototype export extern(C) { int SDL_Init(Uint32 flags); } BTW what does a Acces Violation mean?Yep, unfortunately the objconv doesn't always work so good, probably because dmd uses a somewhat modified OMF IIRC. http://en.wikipedia.org/wiki/Access_violation
Aug 03 2010