1

My code:

import gtk.MainWindow;
import gtk.Main;

void main(string[] args)
{
    Main.init(args);
    auto win=new MainWindow("Hello World");
    win.setDefaultSize(200,100);
    win.showAll();
    Main.run();
}

When I try to compile with DMD (or gdc), I get the errors:

dmd ./test.d -L-L/usr/local/include/d/gtkd-2/lib
test.o:(.data+0x10): undefined reference to `_D3gtk10MainWindow12__ModuleInfoZ'
test.o:(.data+0x18): undefined reference to `_D3gtk4Main12__ModuleInfoZ'
test.o: In function `_Dmain':
./test.d:(.text._Dmain+0x15): undefined reference to `_D3gtk4Main4Main4initFKAAyaZv'
./test.d:(.text._Dmain+0x1b): undefined reference to `_D3gtk10MainWindow10MainWindow7__ClassZ'
./test.d:(.text._Dmain+0x3a): undefined reference to `_D3gtk10MainWindow10MainWindow6__ctorMFAyaZC3gtk10MainWindow10MainWindow'
./test.d:(.text._Dmain+0x68): undefined reference to `_D3gtk4Main4Main3runFZv'
test.o:(.data._D67TypeInfo_S3std8typecons35__T6scopedTC5cairo7Context7ContextZ6Scoped6__initZ+0x58): undefined reference to `_D3std8typecons35__T6scopedTC5cairo7Context7ContextZ6Scoped6__dtorMFZv'
collect2: error: ld returned 1 exit status
--- errorlevel 1

I have spent the last two days trying to compile this simple hello world app and have looked at multiple websites, including this one. I have tried the linking tricks that others have proposed but without success. I have GtkD and gtk+ both installed (I have used gtk with C, so I know that part is working correctly) It does not seem to matter if I use dmd or gdc (currently using dmd as I found more online solutions for that compiler).

I should also say that regular, non-gui D code compiles fine. It is when I attempt to use GtkD that this occurs.

savanto
  • 4,470
  • 23
  • 40
user3529893
  • 109
  • 6
  • 1
    the linker is missing the gtkD libs, make sure the lib path include the proper lib folders – ratchet freak May 26 '14 at 08:36
  • How should I do this? I've tried: dmd $(pkg-config --cflags --libs gtkd-2) ./test.d, dmd (and gdc) test.d -I/usr/local/include/d/gtk-2 -l/usr/local/lib, dmd (and gdc) -L/usr/local/include/d/gtkd-2/ -l/usr/local/include/d/gtk-2/gtk ./test.d and several others. – user3529893 May 26 '14 at 18:08
  • Nevermind. The correct command was gdc ./test.d -Wall `pkg-config --cflags --libs gtkd-2` -I/usr/include/d/gtkd-2 -L/usr/local/lib -lpq. Thanks for your help. – user3529893 May 26 '14 at 18:48
  • you should post an answer to yourself so the question looks complete – Adam D. Ruppe May 26 '14 at 23:47

1 Answers1

1

I found the answer. It is:

gdc ./test.d -Wall pkg-config --cflags --libs gtkd-2 -I/usr/include/d/gtkd-2 -L/usr/local/lib -lpq

user3529893
  • 109
  • 6