## 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...
• Mafi (9/17) Aug 03 2010 Thanks, it's a great utility. Converting and dumping works fine. My
• Trass3r (3/8) Aug 03 2010 Yep, unfortunately the objconv doesn't always work so good, probably
Mafi <mafi example.org> writes:
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.

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
Mafi <mafi example.org> writes:
Ok,
symbol (good) and creates a corrupt executable (so-so). With linking SDL
in any way (explicitly or with pragma(lib)) it shows no errormessage
Should I fill a bug report or am I doing something wrong?

Aug 01 2010
Mike Parker <aldacron gmail.com> writes:
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.

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
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.

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

Aug 01 2010
Mafi <mafi example.org> writes:
 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
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.

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

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

Aug 01 2010
div0 <div0 sourceforge.net> writes:
On 01/08/2010 16:22, Mafi wrote:
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
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.

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

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

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.

Aug 01 2010
Mike Parker <aldacron gmail.com> writes:
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


Aug 01 2010
Mafi <mafi example.org> writes:
Am 02.08.2010 06:16, schrieb Mike Parker:
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,

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.
Mafi

Aug 02 2010
Trass3r <un known.com> writes:
 [1] http://www.digitalmars.com/ctg/coff2omf.html

The tool sounds cool but it seems that I have to buy it, so that's no
option for me.

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

Aug 02 2010
Mafi <mafi example.org> writes:
Am 02.08.2010 16:19, schrieb Trass3r:
[1] http://www.digitalmars.com/ctg/coff2omf.html

The tool sounds cool but it seems that I have to buy it, so that's no
option for me.

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

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?

Mafi

Aug 03 2010
Trass3r <un known.com> writes:
 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