未定义的符号“开始";通过LD链接D程序时 [英] Undefined symbol "start" while linking D program through LD

查看:130
本文介绍了未定义的符号“开始";通过LD链接D程序时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下简单程序:

import std.stdio;

int main(string[] argv) {
    writeln("Hello, world!");

    return 0;
}

我正在如下构建它:

DMD -c -m64 -od/proj/out -w -wi -fPIC -debug \
    -g -I/proj/hello -unittest /proj/hello.d

LD -L/usr/share/dmd/lib/ -arch x86_64 -execute -macosx_version_min 10.7 \
    -pie -lm -lpthread -lphobos2 -o /proj/out/hello_app /proj/out/hello.o

编译通过得很顺利,但是将卡纸与以下内容联系起来:

Compilation passes perfectly, but linking stucks with following:

Undefined symbols for architecture x86_64:
  "start", referenced from:
     -u command line option
     (maybe you meant: _D3std9algorithm41__T10startsWithVAyaa6_61203d3d2062TAhTAhZ10startsWithFAhAhZb, _D4core6thread6Thread5startMFZv , _D3std9algorithm91__T10startsWithVAyaa11_62203c20612e74696d6554TAS3std8datetime13PosixTimeZone10TransitionTlZ10startsWithFAS3std8datetime13PosixTimeZone10TransitionlZb , _D3std9algorithm43__T10startsWithVAyaa6_61203d3d2062TAyaTAyaZ10startsWithFAyaAyaZb , _D3std9algorithm41__T10startsWithVAyaa6_61203d3d2062TAxaTaZ10startsWithFAxaaZb , _D3std9algorithm92__T10startsWithVAyaa11_62203c20612e74696d6554TAS3std8datetime13PosixTimeZone10LeapSecondTylZ10startsWithFAS3std8datetime13PosixTimeZone10LeapSecondylZb , _D3std9algorithm92__T10startsWithVAyaa11_62203c20612e74696d6554TAS3std8datetime13PosixTimeZone10TransitionTylZ10startsWithFAS3std8datetime13PosixTimeZone10TransitionylZb )
ld: symbol(s) not found for architecture x86_64

我想我忘了要链接的其他静态库以设置所有内容,但是究竟是什么呢?

I guess I forgot some additional static library to link with to have it setup everything, but what exactly?

我也看过有关如何进行单独编译以及在dlang网站上某个地方链接的说明,但是找不到它.

Also I've seen instructions about how to do separate compilation and linking somewhere on dlang site, but cannot find it.

UPD1::使用gcc -L/usr/share/dmd/lib/ -lphobos2 -lm -lpthread hello.o在GCC的帮助下进行链接时,它可以工作,但是我需要使用ld.

UPD1: When linking with help of GCC using gcc -L/usr/share/dmd/lib/ -lphobos2 -lm -lpthread hello.o, it works, but I need to use ld.

推荐答案

链接时添加-lcrt1.o.

LD -L/usr/share/dmd/lib/ -arch x86_64 -execute -macosx_version_min 10.7 \
  -pie -lm -lpthread -lphobos2 -lcrt1.o -o /proj/out/hello_app /proj/out/hello.o

[更新] 啊,你懂了:)

[update] Ah, you got it : )

这篇关于未定义的符号“开始";通过LD链接D程序时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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