Thread overview |
---|
February 09, 2004 D in Linux | ||||
---|---|---|---|---|
| ||||
Yo -- I'm trying to compile the following source: int main(char[][] args) { return 0; } And I get a couple of unresolved externals: $ dmd main.d gcc main.o -o main -lphobos -lpthread -lm -Xlinker -L/opt/dmd/lib /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../crt1.o(.text+0x18): In function `_start': : undefined reference to `main' main.o(.gnu.linkonce.t_assert_4main+0x11): In function `_assert_4main': : undefined reference to `_d_assert' collect2: ld returned 1 exit status As far as I can tell, I'm following the documentation pretty closely. Does anyone know what I'm doing wrong? -- John |
February 09, 2004 Re: D in Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to John | It looks like libphobos.a is not being found. Did you put it in /usr/lib ? "John" <John_member@pathlink.com> wrote in message news:c08t30$155e$1@digitaldaemon.com... > Yo -- > > I'm trying to compile the following source: > > int main(char[][] args) > { > return 0; > } > > And I get a couple of unresolved externals: > > $ dmd main.d > gcc main.o -o main -lphobos -lpthread -lm -Xlinker -L/opt/dmd/lib > /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../crt1.o(.text+0x18): In > function `_start': > : undefined reference to `main' > main.o(.gnu.linkonce.t_assert_4main+0x11): In function `_assert_4main': > : undefined reference to `_d_assert' > collect2: ld returned 1 exit status > > As far as I can tell, I'm following the documentation pretty closely. Does > anyone know what I'm doing wrong? > > -- John > > |
February 09, 2004 Re: D in Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | It's finding it -- it would say 'could not find -lphobos' when it couldn't. Anyone have any other ideas? In article <c09150$1c2k$1@digitaldaemon.com>, Walter says... > >It looks like libphobos.a is not being found. Did you put it in /usr/lib ? > >"John" <John_member@pathlink.com> wrote in message news:c08t30$155e$1@digitaldaemon.com... >> Yo -- >> >> I'm trying to compile the following source: >> >> int main(char[][] args) >> { >> return 0; >> } >> >> And I get a couple of unresolved externals: >> >> $ dmd main.d >> gcc main.o -o main -lphobos -lpthread -lm -Xlinker -L/opt/dmd/lib >> /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../crt1.o(.text+0x18): In >> function `_start': >> : undefined reference to `main' >> main.o(.gnu.linkonce.t_assert_4main+0x11): In function `_assert_4main': >> : undefined reference to `_d_assert' >> collect2: ld returned 1 exit status >> >> As far as I can tell, I'm following the documentation pretty closely. >Does >> anyone know what I'm doing wrong? >> >> -- John >> >> > > |
February 09, 2004 Re: D in Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to John | On Mon, 09 Feb 2004 23:16:45 +0000, John wrote:
> It's finding it -- it would say 'could not find -lphobos' when it couldn't.
>
> Anyone have any other ideas?
>
> In article <c09150$1c2k$1@digitaldaemon.com>, Walter says...
>>
>>It looks like libphobos.a is not being found. Did you put it in /usr/lib ?
>>
>>"John" <John_member@pathlink.com> wrote in message news:c08t30$155e$1@digitaldaemon.com...
>>> Yo --
>>>
>>> I'm trying to compile the following source:
>>>
>>> int main(char[][] args)
>>> {
>>> return 0;
>>> }
>>>
>>> And I get a couple of unresolved externals:
>>>
>>> $ dmd main.d
>>> gcc main.o -o main -lphobos -lpthread -lm -Xlinker -L/opt/dmd/lib
>>> /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../crt1.o(.text+0x18): In
>>> function `_start':
>>> : undefined reference to `main'
>>> main.o(.gnu.linkonce.t_assert_4main+0x11): In function `_assert_4main':
>>> : undefined reference to `_d_assert'
>>> collect2: ld returned 1 exit status
>>>
>>> As far as I can tell, I'm following the documentation pretty closely.
>>Does
>>> anyone know what I'm doing wrong?
>>>
>>> -- John
>>>
>>>
>>
>>
you need something like:
dmd main.d -I~/dmd/src/phobos
|
February 10, 2004 Re: D in Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ant | I've got that in my dmd.conf: [Environment] DFLAGS=-I/opt/dmd/src/phobos -L-L/opt/dmd/lib I don't think the problem is of the nature 'can't find some file.' It gets to the linking stage, and when it throws everything together, there are some unresolved externals. If it couldn't find some file I'm sure it would complain specifically about that. -- John In article <pan.2004.02.09.23.31.43.879205@yahoo.ca>, Ant says... > >On Mon, 09 Feb 2004 23:16:45 +0000, John wrote: > >> It's finding it -- it would say 'could not find -lphobos' when it couldn't. >> >> Anyone have any other ideas? >> > >you need something like: >dmd main.d -I~/dmd/src/phobos > |
February 10, 2004 Re: D in Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to John | Those unresolved symbols are in libphobos.a. "John" <John_member@pathlink.com> wrote in message news:c094ct$1h9n$1@digitaldaemon.com... > It's finding it -- it would say 'could not find -lphobos' when it couldn't. > > Anyone have any other ideas? > > In article <c09150$1c2k$1@digitaldaemon.com>, Walter says... > > > >It looks like libphobos.a is not being found. Did you put it in /usr/lib ? > > > >"John" <John_member@pathlink.com> wrote in message news:c08t30$155e$1@digitaldaemon.com... > >> Yo -- > >> > >> I'm trying to compile the following source: > >> > >> int main(char[][] args) > >> { > >> return 0; > >> } > >> > >> And I get a couple of unresolved externals: > >> > >> $ dmd main.d > >> gcc main.o -o main -lphobos -lpthread -lm -Xlinker -L/opt/dmd/lib > >> /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../crt1.o(.text+0x18): In > >> function `_start': > >> : undefined reference to `main' > >> main.o(.gnu.linkonce.t_assert_4main+0x11): In function `_assert_4main': > >> : undefined reference to `_d_assert' > >> collect2: ld returned 1 exit status > >> > >> As far as I can tell, I'm following the documentation pretty closely. > >Does > >> anyone know what I'm doing wrong? > >> > >> -- John > >> > >> > > > > > > |
February 10, 2004 Re: D in Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | This is what happens when I change dmd.conf so that it can no longer find libphobos.a: /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../../i686-pc-linux-gnu/bin/ld: cannot find -lphobos So I'm rather positive that it's finding libphobos.a normally... -- John In article <c0a4p0$64a$1@digitaldaemon.com>, Walter says... > >Those unresolved symbols are in libphobos.a. > >"John" <John_member@pathlink.com> wrote in message news:c094ct$1h9n$1@digitaldaemon.com... >> It's finding it -- it would say 'could not find -lphobos' when it >couldn't. >> >> Anyone have any other ideas? >> >> In article <c09150$1c2k$1@digitaldaemon.com>, Walter says... >> > >> >It looks like libphobos.a is not being found. Did you put it in /usr/lib >? >> > >> >"John" <John_member@pathlink.com> wrote in message news:c08t30$155e$1@digitaldaemon.com... >> >> Yo -- >> >> >> >> I'm trying to compile the following source: >> >> >> >> int main(char[][] args) >> >> { >> >> return 0; >> >> } >> >> >> >> And I get a couple of unresolved externals: >> >> >> >> $ dmd main.d >> >> gcc main.o -o main -lphobos -lpthread -lm -Xlinker -L/opt/dmd/lib >> >> /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../crt1.o(.text+0x18): >In >> >> function `_start': >> >> : undefined reference to `main' >> >> main.o(.gnu.linkonce.t_assert_4main+0x11): In function `_assert_4main': >> >> : undefined reference to `_d_assert' >> >> collect2: ld returned 1 exit status >> >> >> >> As far as I can tell, I'm following the documentation pretty closely. >> >Does >> >> anyone know what I'm doing wrong? >> >> >> >> -- John >> >> >> >> >> > >> > >> >> > > |
February 11, 2004 Re: D in Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to John | Okay, I think I've got at least some part of it fixed. Apparently, when linking with static libraries (I'm pretty sure dynamic libraries don't have this problem), the order in which they're given to the linker is important. By default, D executes gcc main.o -o main -lphobos -lpthread -lm -Xlinker -L/opt/dmd/lib Whereas libphobos needs to be placed before main.o. When I run GCC myself and rearrange things to look like gcc -L/opt/dmd/lib -lphobos -lpthread -lm -Xlinker main.o -o main Then I'm down to one unresolved external: main.o(.gnu.linkonce.t_assert_4main+0x11): In function `_assert_4main': : undefined reference to `_d_assert' So it looks like now it's finding main -- but obviously I'm still having trouble with _d_assert. Is this also part of libphobos? Is there a debug library I need to link against to get _d_assert? Thanks much, John >In article <c0a4p0$64a$1@digitaldaemon.com>, Walter says... >> >>Those unresolved symbols are in libphobos.a. >> >>"John" <John_member@pathlink.com> wrote in message news:c094ct$1h9n$1@digitaldaemon.com... >>> It's finding it -- it would say 'could not find -lphobos' when it >>couldn't. >>> >>> Anyone have any other ideas? >>> >>> In article <c09150$1c2k$1@digitaldaemon.com>, Walter says... >>> > >>> >It looks like libphobos.a is not being found. Did you put it in /usr/lib >>? >>> > >>> >"John" <John_member@pathlink.com> wrote in message news:c08t30$155e$1@digitaldaemon.com... >>> >> Yo -- >>> >> >>> >> I'm trying to compile the following source: >>> >> >>> >> int main(char[][] args) >>> >> { >>> >> return 0; >>> >> } >>> >> >>> >> And I get a couple of unresolved externals: >>> >> >>> >> $ dmd main.d >>> >> gcc main.o -o main -lphobos -lpthread -lm -Xlinker -L/opt/dmd/lib >>> >> /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../crt1.o(.text+0x18): >>In >>> >> function `_start': >>> >> : undefined reference to `main' >>> >> main.o(.gnu.linkonce.t_assert_4main+0x11): In function `_assert_4main': >>> >> : undefined reference to `_d_assert' >>> >> collect2: ld returned 1 exit status >>> >> >>> >> As far as I can tell, I'm following the documentation pretty closely. >>> >Does >>> >> anyone know what I'm doing wrong? >>> >> >>> >> -- John >>> >> >>> >> >>> > >>> > >>> >>> >> >> > > |
February 12, 2004 Re: D in Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to John | _d_assert is defined by module std.asserterror, and it should be in the library. (To find where names are defined, the following is very handy: cd \dmd\src\phobos grep -r d_assert *.d ) "John" <John_member@pathlink.com> wrote in message news:c0cj4h$14eg$1@digitaldaemon.com... > Okay, I think I've got at least some part of it fixed. Apparently, when linking > with static libraries (I'm pretty sure dynamic libraries don't have this problem), the order in which they're given to the linker is important. By default, D executes > > gcc main.o -o main -lphobos -lpthread -lm -Xlinker -L/opt/dmd/lib > > Whereas libphobos needs to be placed before main.o. When I run GCC myself and > rearrange things to look like > > gcc -L/opt/dmd/lib -lphobos -lpthread -lm -Xlinker main.o -o main > > Then I'm down to one unresolved external: > > main.o(.gnu.linkonce.t_assert_4main+0x11): In function `_assert_4main': : undefined reference to `_d_assert' > > So it looks like now it's finding main -- but obviously I'm still having trouble > with _d_assert. Is this also part of libphobos? Is there a debug library I > need to link against to get _d_assert? > > Thanks much, > John > > >In article <c0a4p0$64a$1@digitaldaemon.com>, Walter says... > >> > >>Those unresolved symbols are in libphobos.a. > >> > >>"John" <John_member@pathlink.com> wrote in message news:c094ct$1h9n$1@digitaldaemon.com... > >>> It's finding it -- it would say 'could not find -lphobos' when it > >>couldn't. > >>> > >>> Anyone have any other ideas? > >>> > >>> In article <c09150$1c2k$1@digitaldaemon.com>, Walter says... > >>> > > >>> >It looks like libphobos.a is not being found. Did you put it in /usr/lib > >>? > >>> > > >>> >"John" <John_member@pathlink.com> wrote in message news:c08t30$155e$1@digitaldaemon.com... > >>> >> Yo -- > >>> >> > >>> >> I'm trying to compile the following source: > >>> >> > >>> >> int main(char[][] args) > >>> >> { > >>> >> return 0; > >>> >> } > >>> >> > >>> >> And I get a couple of unresolved externals: > >>> >> > >>> >> $ dmd main.d > >>> >> gcc main.o -o main -lphobos -lpthread -lm -Xlinker -L/opt/dmd/lib > >>> >> /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../crt1.o(.text+0x18): > >>In > >>> >> function `_start': > >>> >> : undefined reference to `main' > >>> >> main.o(.gnu.linkonce.t_assert_4main+0x11): In function `_assert_4main': > >>> >> : undefined reference to `_d_assert' > >>> >> collect2: ld returned 1 exit status > >>> >> > >>> >> As far as I can tell, I'm following the documentation pretty closely. > >>> >Does > >>> >> anyone know what I'm doing wrong? > >>> >> > >>> >> -- John > >>> >> > >>> >> > >>> > > >>> > > >>> > >>> > >> > >> > > > > > > |
February 12, 2004 Re: D in Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
> _d_assert is defined by module std.asserterror, and it should be in the
> library.
>
> (To find where names are defined, the following is very handy:
> cd \dmd\src\phobos
> grep -r d_assert *.d
> )
Just a minor clarification: the command should be
grep -r d_assert .
With -r (recurse), grep takes directories as arguments. You can pass it files as arguments, but it won't recurse into directories unles you give them on the command line.
Russ
|
Copyright © 1999-2021 by the D Language Foundation