我想直接使用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