GTKD未定义参考 [英] GtkD undefined reference

查看:141
本文介绍了GTKD未定义参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码:

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();
}

当我尝试使用DMD(或gdc)进行编译时,出现错误:

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

我花了最后两天的时间来尝试编译这个简单的hello world应用程序,并查看了多个网站,包括该网站.我尝试了其他人提出的链接技巧,但没有成功.我同时安装了GtkD和gtk +(我已经将gtk与C一起使用,所以我知道该部件可以正常工作)使用dmd还是gdc似乎无关紧要(当前使用的是dmd,因为我发现了该编译器的更多在线解决方案)

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).

我还应该说,常规的非GUI D代码可以很好地编译.这是我尝试使用GtkD时发生的情况.

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

推荐答案

我找到了答案.它是:

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

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

这篇关于GTKD未定义参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆