View previous topic :: View next topic |
Author |
Message |
nazarel
Joined: 01 May 2009 Posts: 8 Location: Houston
|
Posted: Fri May 01, 2009 7:59 pm Post subject: Convert the gtkD source files |
|
|
How do you convert the gtkD source files into a shared object or other type of library file?
I'm trying to write an example code for gtkD and trying to compile it in Code::Blocks IDE. I've read the documentation on CodeBlocks, and it says I need to add the library file in the linker settings. The file types it accepts are .a, .so, .lib, .dylib, and .bundle - how do I convert the gtkD source files into one of these file formats?
Any help would be appreciated!
(I've already tried searching the fourms, but I can't find the right info). |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Sat May 02, 2009 5:03 am Post subject: |
|
|
You can build the library with DSSS by executing the following from the GtkD folder.
this will create a bunch of *.a (linux) or *.lib (windows) files you can use.
Also see: http://www.dsource.org/projects/gtkd/wiki/BuildingWithDSSS
Alternatively there is a makefile for Linux and Mac. executing:
Will build a static libraries for GtkD, GtkDGL and Sourceview, that you can use.
Optionally you can install the libraries with:
or
This will put the libraries and the source in /usr/local/ this isn't always needed as you can point Codeblocks to the files where they are without installing. |
|
Back to top |
|
|
nazarel
Joined: 01 May 2009 Posts: 8 Location: Houston
|
Posted: Sat May 02, 2009 11:21 am Post subject: got the libgktd.a installed |
|
|
I ran make and (sudo) make install and I got the libgtkd.a installed within usr/local/lib. I pointed Code::Blocks to libgtkd.a under the Project > Build Options > Linker Settings. I then added the d folder ( under usr/local/gtkD/include/d ) to the Project > Build Options > Search Directories > Compiler, Linker, and Resource Compiler tabs. However when I build the project (hello.d) in Code::Blocks - it gives me these errors:
Code: | Loader .d: (.text+0x54) Undefined reference to 'dlsym'
Loader .d ... Undefined reference to 'dlerror'
Loader .d ... Undefined reference to 'dlopen'
Loader .d ... Undefined reference to 'dlclose' |
Here's the code for the project I'm trying to build (it's from the gtkD Dsource examples):
Code: |
import gtk.MainWindow;
import gtk.Label;
import gtk.Main;
void main(char[][] args)
{
Main.init(args);
MainWindow win = new MainWindow("Hello World");
win.setDefaultSize(200, 100);
win.add(new Label("Hello World"));
win.showAll();
Main.run();
}
|
Thanks for the help getting the libgtkd.a installed! |
|
Back to top |
|
|
kaarna
Joined: 03 Apr 2006 Posts: 92 Location: Finland
|
Posted: Sat May 02, 2009 11:49 am Post subject: |
|
|
I don't know anything about Code::Blocks, but I guess you need to link in libdl. On the command line this is done usually with -ldl or -L-ldl, but in Code::Blocks you propably need to add the library to your project from somewhere like /usr/lib/libdl.so or libdl.a. I can't check if those are the exact names, as I'm not writing this on linux. But it should be something like that...
libdl will enable gtkD to load the GTK+ and other libraries dynamically while your program is running. |
|
Back to top |
|
|
nazarel
Joined: 01 May 2009 Posts: 8 Location: Houston
|
Posted: Sat May 02, 2009 12:34 pm Post subject: Almost there... |
|
|
Ok, I linked in the libdl.a from usr/lib - it gave me some more errors about _dlopen, etc. - so I linked in libc.a
It now compiles with the warning:
Code: | Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking |
The code runs, but in the terminal it reads:
Thanks for da info! |
|
Back to top |
|
|
kaarna
Joined: 03 Apr 2006 Posts: 92 Location: Finland
|
Posted: Sat May 02, 2009 2:05 pm Post subject: |
|
|
Maybe, if you haven't already done so, you could first test your environment by using DSSS to build gtkD and some demos. http://www.dsource.org/projects/gtkd/wiki/BuildingWithDSSS
And if that works, I think that after that point it's pretty much a question of how Code::Blocks works with linking libraries, so you might need to ask someone who knows that particular IDE. |
|
Back to top |
|
|
nazarel
Joined: 01 May 2009 Posts: 8 Location: Houston
|
Posted: Sat May 02, 2009 4:27 pm Post subject: Posted in CodeBlocks forum |
|
|
I posted my question in the Code::Blocks forum - I'll see if they can help. Thanks kaarna and mike! |
|
Back to top |
|
|
Mike Wey
Joined: 07 May 2007 Posts: 428
|
Posted: Sun May 03, 2009 7:50 am Post subject: Re: Almost there... |
|
|
nazarel wrote: | Ok, I linked in the libdl.a from usr/lib - it gave me some more errors about _dlopen, etc. - so I linked in libc.a
It now compiles with the warning:
Code: | Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking |
The code runs, but in the terminal it reads:
Thanks for da info! |
Try libdl.so this is whats normally linked in. Or add -ldl to the linker options instead of pointing it to the library, if Codeblocks allows you to do that. |
|
Back to top |
|
|
|