我想直接使用D和我在Github上找到的绑定(https://github.com/madadam/X11.d)来使用Xlib。使用Xlib的XCreateSimpleWindow访问冲突
问题是我在几个函数(例如XCreateSimpleWindow)中出现访问冲突。我创建了一个最小示例:
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);
}
我使用Fedora 20和dmd 2.066。
编辑1: @ user3661500问我发布的应用程序的输出:
Access violation (dump written)
提示:我有,因为我的系统来翻译它的语言是德语。
编辑2: @Adam D. Ruppe:想你的文件时,我得到一个链接错误:
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
预先感谢您!
你可以尝试在'scope(failure)'语句中测试w的值吗?也许它会匹配其中一个[** XErrorCode值**](https://github.com/madadam/X11.d/blob/428990591bc2726f0555b137a6cc9e64a893fd9b/X11/X.d#L325)。 – 2014-10-26 16:12:43
请注意[**这些X11绑定**](https://github.com/nomad-software/x11)似乎更可靠。 – 2014-10-26 16:23:23
w的值与任何错误代码都不匹配,并且也会有所不同。当使用你提到的X11绑定时,我得到一个链接错误:'test.o:In function'_Dmain': test.d :(。text._Dmain + 0x57):对DefaultRootWindow的未定义引用 – user3684240 2014-10-26 16:50:32