问题
I use Fedora20 and I install gtkd via sudo yum install gtkd
How to compile gtk this code ?
import gtk.MainWindow;
import gtk.Label;
import gtk.Main;
void main(string[] args)
{
Main.init(args);
MainWindow win = new MainWindow("Hello World");
win.setDefaultSize(200, 100);
win.add(new Label("Hello World"));
win.showAll();
Main.run();
}
but i get this error
➜ /tmp dmd -L-lgtkd -L-ldl main.d main.d(1): Error: module MainWindow is in file 'gtk/MainWindow.d' which cannot be read import path[0] = /usr/include/dmd/phobos import path[1] = /usr/include/dmd/druntime/import
Please help me.
回答1:
If you use gtkd-devel
package provided by Fedora, you should know that it is linked against libphobos-ldc
library which you will get once you install ldc2
package (yum install ldc2
will do).
This does not yet solve your problem though... gtkd-devel package installs gtkd D interface modules into the /usr/include/d/gtkd-2
folder. So, in order to compile your GtkD application you need to execute something like (assuming your D file has name "firstwin.d"): ldc2 -I/usr/include/d/gtkd-2 -L-lgtkd-2 firstwin.d
来源:https://stackoverflow.com/questions/23542478/gtkd-with-d-lang-on-fedora