Reputation: 1580
I'm trying to use Xlib directly using D and bindings I found on Github (https://github.com/madadam/X11.d).
The problem is that I get an access violation in several functions (e.g. XCreateSimpleWindow). I created a minimal example:
module test;
import X11.Xlib;
import std.stdio;
void main()
{
Display* d = XOpenDisplay(null);
assert(!(d is null));
Window w = XCreateSimpleWindow(d, DefaultRootWindow(d), 0, 0, 200, 100, 0, 0, 0);
}
I use Fedora 20 and dmd 2.066.
Edit 1: @user3661500 asked me to publish the applications' output:
Access violation (dump written)
Hint: I had to translate it because my systems' language is german.
Edit 2: @Adam D. Ruppe: I get a linking error when trying your files:
dmd color.d static.d simpledisplay.d -L-lX11
/usr/bin/ld: color.o: undefined reference to symbol 'XShmPutImage'
/usr/bin/ld: note: 'XShmPutImage' is defined in DSO /lib64/libXext.so.6 so try adding it to the linker command line
/lib64/libXext.so.6: could not read symbols: Invalid operation
Thank you in advance!
Upvotes: 2
Views: 206
Reputation: 25595
The Xlib bindings you are using aren't 64-bit compatible. (They use int
or long
in places where it should be c_long
, a common mistake when doing bindings from C as a long in C isn't necessarily the same as a long in D)
You can fix the bindings by finding those instances in the documentation, but easier would be to compile for 32 bit with dmd -m32
or find another set of bindings that are 64 bit compatible. My simpledisplay.d has tackled this problem before, the binding code is found here: https://github.com/adamdruppe/arsd/blob/master/simpledisplay.d#L3605 and is about 1500 lines long.
Upvotes: 1