Thread overview
gtkd
Jan 05, 2008
llee
Jan 05, 2008
Bill Baxter
Jan 05, 2008
llee
Jan 06, 2008
Jarrod
Jan 06, 2008
Alan Knowles
Jan 07, 2008
John Reimer
Jan 06, 2008
Sean Reque
January 05, 2008
I'm trying to compile a program to use gtkd, however, I don't know what options I should pass to the d compiler.

I'm using dmd to compile a test program. I'm using one of the example provided on gtkd's dsource website:

import gtk.MainWindow;
import gtk.Label;
import gtk.GtkD;

void main(char[][] args)
{
	GtkD.init(args);
	MainWindow win = new MainWindow("Hello World");
	win.setDefaultSize(200, 100);
	win.add(new Label("Hello World"));
	win.showAll();

	GtkD.main();
}

When I run dmd gtk_example.d, the compiler threw an error stating that it could not find gtk/MainWindow.d.

I did a search for the file and found that dsss had created a gtk directory under /usr/local/include/d/, where /usr/local was the prefix that I used during the build. I copied the program that I'm trying to compile to /usr/local/include/d and tried to recompile it. This time It returned a number of 'undefined reference' errors. For example:

gtk_example.o: (.data+0x30): undefined reference to   '_D3gtk10MainWindow12__ModuleInfoZ'

It seems that I need to compile against a library. The instructions provided on gtkd's dsource page say that I need to use gcc to handle linking, and gives the following example:

dmd myprog.d -c
gcc myprog.o -o myprog -lm -lpthread -ldl -lgtkd -lphobos

It seems that I'm missing the gtkd library. I'm guessing from ld's usage conventions, that the library should be named libgtkd.a. I did a search for this library and the closest thing that appeared was libDD-gtk.a. I tried linking against this and it failed. At the moment I'm out of ideas.

Any help would be appreciated.

January 05, 2008
llee wrote:
> I'm trying to compile a program to use gtkd, however, I don't know what options I should pass to the d compiler. 
> 
> I'm using dmd to compile a test program. I'm using one of the example provided on gtkd's dsource website: 
> 
> import gtk.MainWindow;
> import gtk.Label;
> import gtk.GtkD;
> 
> void main(char[][] args)
> {
> 	GtkD.init(args);
> 	MainWindow win = new MainWindow("Hello World");
> 	win.setDefaultSize(200, 100);
> 	win.add(new Label("Hello World"));
> 	win.showAll();
> 
> 	GtkD.main();
> }
> 
> When I run dmd gtk_example.d, the compiler threw an error stating that it could not find gtk/MainWindow.d. 
> 
> I did a search for the file and found that dsss had created a gtk directory under /usr/local/include/d/, where /usr/local was the prefix that I used during the build. I copied the program that I'm trying to compile to /usr/local/include/d and tried to recompile it. This time It returned a number of 'undefined reference' errors. For example:
> 
> gtk_example.o: (.data+0x30): undefined reference to   '_D3gtk10MainWindow12__ModuleInfoZ'
> 
> It seems that I need to compile against a library. The instructions provided on gtkd's dsource page say that I need to use gcc to handle linking, and gives the following example: 
> 
> dmd myprog.d -c
> gcc myprog.o -o myprog -lm -lpthread -ldl -lgtkd -lphobos
> 
> It seems that I'm missing the gtkd library. I'm guessing from ld's usage conventions, that the library should be named libgtkd.a. I did a search for this library and the closest thing that appeared was libDD-gtk.a. I tried linking against this and it failed. At the moment I'm out of ideas.
> 
> Any help would be appreciated.
> 

If you used dsss to download/install gtk then you should probably be using dsss to compile it:

dsss build myprog

With a simple one-line dsss.conf containing:

[myprog.d]

--bb
January 05, 2008
Bill Baxter Wrote:

> llee wrote:
> > I'm trying to compile a program to use gtkd, however, I don't know what options I should pass to the d compiler.
> > 
> > I'm using dmd to compile a test program. I'm using one of the example provided on gtkd's dsource website:
> > 
> > import gtk.MainWindow;
> > import gtk.Label;
> > import gtk.GtkD;
> > 
> > void main(char[][] args)
> > {
> > 	GtkD.init(args);
> > 	MainWindow win = new MainWindow("Hello World");
> > 	win.setDefaultSize(200, 100);
> > 	win.add(new Label("Hello World"));
> > 	win.showAll();
> > 
> > 	GtkD.main();
> > }
> > 
> > When I run dmd gtk_example.d, the compiler threw an error stating that it could not find gtk/MainWindow.d.
> > 
> > I did a search for the file and found that dsss had created a gtk directory under /usr/local/include/d/, where /usr/local was the prefix that I used during the build. I copied the program that I'm trying to compile to /usr/local/include/d and tried to recompile it. This time It returned a number of 'undefined reference' errors. For example:
> > 
> > gtk_example.o: (.data+0x30): undefined reference to   '_D3gtk10MainWindow12__ModuleInfoZ'
> > 
> > It seems that I need to compile against a library. The instructions provided on gtkd's dsource page say that I need to use gcc to handle linking, and gives the following example:
> > 
> > dmd myprog.d -c
> > gcc myprog.o -o myprog -lm -lpthread -ldl -lgtkd -lphobos
> > 
> > It seems that I'm missing the gtkd library. I'm guessing from ld's usage conventions, that the library should be named libgtkd.a. I did a search for this library and the closest thing that appeared was libDD-gtk.a. I tried linking against this and it failed. At the moment I'm out of ideas.
> > 
> > Any help would be appreciated.
> > 
> 
> If you used dsss to download/install gtk then you should probably be using dsss to compile it:
> 
> dsss build myprog
> 
> With a simple one-line dsss.conf containing:
> 
> [myprog.d]
> 
> --bb

I created a new directory containing the example program and a dsss config file. The config file contained the line that you gave me. When I executed dsss build, the compiler threw a number of undefined reference errors. I'm pretty sure that the program needs to be linked against a library to compile. Unfortunately I don't names or locations of these libraries.
January 06, 2008
On Sat, 05 Jan 2008 18:59:45 -0500, llee wrote:

> I created a new directory containing the example program and a dsss config file. The config file contained the line that you gave me. When I executed dsss build, the compiler threw a number of undefined reference errors. I'm pretty sure that the program needs to be linked against a library to compile. Unfortunately I don't names or locations of these libraries.

So you built and installed gtkd with dsss?
That should take care of most imports, but you still need to link against
libdl
Put this in your source file:

version (build) {
     pragma(link, "dl");
}

that should hopefully fix the linker issue.
January 06, 2008

> It seems that I'm missing the gtkd library. I'm guessing from ld's usage conventions, that the library should be named libgtkd.a.

There should be a script somewhere named something like compdgtkD.sh

I think if you run that script it will make the library you need.
January 06, 2008
...snip...
>> 
>> --bb
> 
> I created a new directory containing the example program and a dsss
> config file. The config file contained the line that you gave me.
> When I executed dsss build, the compiler threw a number of undefined
> reference errors. I'm pretty sure that the program needs to be linked
> against a library to compile. Unfortunately I don't names or
> locations of these libraries.

Gtkd uses dlopen() at startup to load all the associated libraries, so you dont have to have them available when you build. The only thing you need is the resuling libgtkD.a file (created from building gtkd)

Looks like the docs are pretty out of date.

compd is the best way to build gtkD stuff, as it's how the developers do stuff...

dmd YOURSOURCEFILE.d   -of/tmp/YOURCODENAME.o  -op  \
-Isrc:LOCATIONOFYOURCODE:/usr/src/gtkD/src -c   -g -I/usr/src/dmd/src/phobos

gcc  /tmp/YOURCODENAME.o -o YOURAPP -m32     -L.. -L. -L/usr/src/dui/gtkD  -lstdc++ -lphobos -lgtkd -ldl -g -m32 -lphobos -lpthread -lm


Should get you going.
Regards
Alan
January 07, 2008
On Mon, 07 Jan 2008 07:57:59 +0800, Alan Knowles wrote:

> ...snip...
>>> 
>>> --bb
>> 
>> I created a new directory containing the example program and a dsss config file. The config file contained the line that you gave me. When I executed dsss build, the compiler threw a number of undefined reference errors. I'm pretty sure that the program needs to be linked against a library to compile. Unfortunately I don't names or locations of these libraries.
> 
> Gtkd uses dlopen() at startup to load all the associated libraries, so you dont have to have them available when you build. The only thing you need is the resuling libgtkD.a file (created from building gtkd)
> 
> Looks like the docs are pretty out of date.
> 
> compd is the best way to build gtkD stuff, as it's how the developers do stuff...
> 
> dmd YOURSOURCEFILE.d   -of/tmp/YOURCODENAME.o  -op  \ -Isrc:LOCATIONOFYOURCODE:/usr/src/gtkD/src -c   -g -I/usr/src/dmd/src/phobos
> 
> gcc  /tmp/YOURCODENAME.o -o YOURAPP -m32     -L.. -L. -L/usr/src/dui/gtkD  -lstdc++ -lphobos -lgtkd -ldl -g -m32 -lphobos -lpthread -lm
> 
> 
> Should get you going.
> Regards
> Alan


Actually, we're working to get things working smoothly with dsss too. But part of the problem with dsss is that some users of it do not "follow the rules" or are confused about what rules they must follow (or they don't read the installation instructions); this tends to cause conflicts.  And then sometimes, it really is dsss' fault, or the config script it uses.  I use dsss pretty much exclusively now while developing gtkd.

dsss is really one of those "exclusive" tools.  That is, if you want it to work, you should be using in exclusively or you may end up with wierd configuration conflicts.

compd is still in there (gktd project) for those that use it... but it's not well documented, which is one reason that makes it less attractive to me.

llee, if you need some more help, you can post on the gtkd forums in dsource.  We can probably help you sort things out better there.

John