GtkD undefined reference

試著忘記壹切 提交于 2019-12-11 05:16:59

问题


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.


回答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



来源:https://stackoverflow.com/questions/23863213/gtkd-undefined-reference

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!