Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
May 20, 2019 stdout does not work in GDC | ||||
---|---|---|---|---|
| ||||
I am following Ali Çehreli's book. It says that stdout.write() should work the same as write() In DMD it works. But when trying to compile with GDC I get the following error: gdc anApp.d -o anApp && ./anApp /usr/bin/ld: /tmp/cc5zJLcW.o: in function `_Dmain': anApp.d:(.text+0x32): undefined reference to `_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File' collect2: error: ld returned 1 exit status Could you please tell me what could be wrong? I am using DMD64 2.086.0 and gdc (Ubuntu 8.3.0-6ubuntu1) 8.3.0 on Ubuntu 19.04/64. |
May 20, 2019 Re: stdout does not work in GDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to D_Boy | On Monday, 20 May 2019 at 08:01:01 UTC, D_Boy wrote:
> I am following Ali Çehreli's book. It says that stdout.write() should work the same as write()
>
> In DMD it works. But when trying to compile with GDC I get the following error:
>
> gdc anApp.d -o anApp && ./anApp
> /usr/bin/ld: /tmp/cc5zJLcW.o: in function `_Dmain':
> anApp.d:(.text+0x32): undefined reference to `_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File'
> collect2: error: ld returned 1 exit status
>
>
> Could you please tell me what could be wrong?
>
> I am using DMD64 2.086.0 and gdc (Ubuntu 8.3.0-6ubuntu1) 8.3.0 on Ubuntu 19.04/64.
Update: the hello world program works fine. Problem appears when I add readf(" %s", &variable)
|
May 20, 2019 Re: stdout does not work in GDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to D_Boy | On Mon, 20 May 2019 at 12:50, D_Boy via D.gnu <d.gnu@puremagic.com> wrote: > > On Monday, 20 May 2019 at 08:01:01 UTC, D_Boy wrote: > > I am following Ali Çehreli's book. It says that stdout.write() > > should work the same as write() > > > > In DMD it works. But when trying to compile with GDC I get the following error: > > > > gdc anApp.d -o anApp && ./anApp > > /usr/bin/ld: /tmp/cc5zJLcW.o: in function `_Dmain': > > anApp.d:(.text+0x32): undefined reference to > > `_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File' > > collect2: error: ld returned 1 exit status > > > > > > Could you please tell me what could be wrong? > > > > I am using DMD64 2.086.0 and gdc (Ubuntu 8.3.0-6ubuntu1) 8.3.0 > > on Ubuntu 19.04/64. > > Update: the hello world program works fine. Problem appears when > I add readf(" %s", &variable) $ gdc-8 test.d -o shared $ nm shared | grep _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File U _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File $ objdump -T /usr/lib/x86_64-linux-gnu/libgphobos.so.76 | grep _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File 000000000034c610 w DF .text 0000000000000070 Base _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File $ gdc-8 test.d -o static -static-libphobos ibuclaw@labs-322:~ $ nm static | grep _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File 000000000002e720 W _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File Can't reproduce, but then again one can't second guess what code you have. In all likelihood you're linking against the wrong library. -- Iain |
May 23, 2019 Re: stdout does not work in GDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw | On Monday, 20 May 2019 at 15:19:27 UTC, Iain Buclaw wrote:
> On Mon, 20 May 2019 at 12:50, D_Boy via D.gnu <d.gnu@puremagic.com> wrote:
>>
>> On Monday, 20 May 2019 at 08:01:01 UTC, D_Boy wrote:
>> > I am following Ali Çehreli's book. It says that stdout.write()
>> > should work the same as write()
>> >
>> > In DMD it works. But when trying to compile with GDC I get the following error:
>> >
>> > gdc anApp.d -o anApp && ./anApp
>> > /usr/bin/ld: /tmp/cc5zJLcW.o: in function `_Dmain':
>> > anApp.d:(.text+0x32): undefined reference to
>> > `_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File'
>> > collect2: error: ld returned 1 exit status
>> >
>> >
>> > Could you please tell me what could be wrong?
>> >
>> > I am using DMD64 2.086.0 and gdc (Ubuntu 8.3.0-6ubuntu1) 8.3.0
>> > on Ubuntu 19.04/64.
>>
>> Update: the hello world program works fine. Problem appears when
>> I add readf(" %s", &variable)
>
> $ gdc-8 test.d -o shared
> $ nm shared | grep
> _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File
> U
> _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File
> $ objdump -T /usr/lib/x86_64-linux-gnu/libgphobos.so.76 | grep
> _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File
> 000000000034c610 w DF .text 0000000000000070 Base
> _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File
>
> $ gdc-8 test.d -o static -static-libphobos
> ibuclaw@labs-322:~ $ nm static | grep
> _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File
> 000000000002e720 W
> _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File
>
> Can't reproduce, but then again one can't second guess what code you have.
>
> In all likelihood you're linking against the wrong library.
Hi! Thanks for your reply!
Here is the not working code(same error as above when trying with GDC):
import std.stdio;
void main(){
int a, b, c;
writeln("Insert three numbers each one followed by hitting Enter key");
readf(" %s", a);
readf(" %s", b);
readf(" %s", c);
if ( a < b && b < c)
writeln(a, b, c);
if ( a > b && b > c)
writeln(c, b, a);
if ( a < c && c < b)
writeln(a, c, b);
if ( b < a && a < c)
writeln(b, a, c);
if ( b < c && c < a)
writeln(b, c, a);
if (a == b && b == c)
writeln(a, b, c);
if ( a == b && b < c)
writeln(a, b, c);
if ( a == b && b > c)
writeln(c, b, a);
if ( a == c && c < b)
writeln(a, c, b);
if ( a == c && c > b)
writeln(b, c, a);
}
I am thinking too the problem is a library linking. Is there anyway to find the wrong linking?
Also, here is the command I am using to compile in GDC:
gdc main.d -o main && ./main
I tried also only to compile it: gdc main.d -o main but got the same error.
I mention again: no problem at all in DMD.
|
May 23, 2019 Re: stdout does not work in GDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to D_Boy | On Thu, 23 May 2019 at 19:35, D_Boy via D.gnu <d.gnu@puremagic.com> wrote: > > On Monday, 20 May 2019 at 15:19:27 UTC, Iain Buclaw wrote: > > On Mon, 20 May 2019 at 12:50, D_Boy via D.gnu <d.gnu@puremagic.com> wrote: > >> > >> On Monday, 20 May 2019 at 08:01:01 UTC, D_Boy wrote: > >> > I am following Ali Çehreli's book. It says that > >> > stdout.write() > >> > should work the same as write() > >> > > >> > In DMD it works. But when trying to compile with GDC I get the following error: > >> > > >> > gdc anApp.d -o anApp && ./anApp > >> > /usr/bin/ld: /tmp/cc5zJLcW.o: in function `_Dmain': > >> > anApp.d:(.text+0x32): undefined reference to > >> > `_D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File' > >> > collect2: error: ld returned 1 exit status > >> > > >> > > >> > Could you please tell me what could be wrong? > >> > > >> > I am using DMD64 2.086.0 and gdc (Ubuntu 8.3.0-6ubuntu1) > >> > 8.3.0 > >> > on Ubuntu 19.04/64. > >> > >> Update: the hello world program works fine. Problem appears > >> when > >> I add readf(" %s", &variable) > > > > $ gdc-8 test.d -o shared > > $ nm shared | grep > > _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File > > U > > _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File > > $ objdump -T /usr/lib/x86_64-linux-gnu/libgphobos.so.76 | grep > > _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File > > 000000000034c610 w DF .text 0000000000000070 Base > > _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File > > > > $ gdc-8 test.d -o static -static-libphobos > > ibuclaw@labs-322:~ $ nm static | grep > > _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File > > 000000000002e720 W > > _D3std5stdio24__T10makeGlobalS6stdoutZ10makeGlobalFNbNcNdNiZS3std5stdio4File > > > > Can't reproduce, but then again one can't second guess what code you have. > > > > In all likelihood you're linking against the wrong library. > > > Hi! Thanks for your reply! > > Here is the not working code(same error as above when trying with > GDC): > > import std.stdio; > > > void main(){ > > int a, b, c; > writeln("Insert three numbers each one followed by hitting > Enter key"); > readf(" %s", a); > readf(" %s", b); > readf(" %s", c); > > if ( a < b && b < c) > writeln(a, b, c); > if ( a > b && b > c) > writeln(c, b, a); > if ( a < c && c < b) > writeln(a, c, b); > if ( b < a && a < c) > writeln(b, a, c); > if ( b < c && c < a) > writeln(b, c, a); > if (a == b && b == c) > writeln(a, b, c); > if ( a == b && b < c) > writeln(a, b, c); > if ( a == b && b > c) > writeln(c, b, a); > if ( a == c && c < b) > writeln(a, c, b); > if ( a == c && c > b) > writeln(b, c, a); > } > > > I am thinking too the problem is a library linking. Is there anyway to find the wrong linking? > > Also, here is the command I am using to compile in GDC: > > gdc main.d -o main && ./main > > I tried also only to compile it: gdc main.d -o main but got the same error. > > I mention again: no problem at all in DMD. And what happens when you compile with -static-libphobos? This confirms whether you are indeed linking against the wrong library or not. -- Iain |
May 27, 2019 Re: stdout does not work in GDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw | On Thursday, 23 May 2019 at 17:39:32 UTC, Iain Buclaw wrote:
> And what happens when you compile with -static-libphobos?
>
> This confirms whether you are indeed linking against the wrong library or not.
gdc main.d -static -libphobos -o main
/usr/bin/ld: cannot find -libphobos
collect2: error: ld returned 1 exit status
|
May 27, 2019 Re: stdout does not work in GDC | ||||
---|---|---|---|---|
| ||||
Posted in reply to D_Boy | On Mon, 27 May 2019 at 09:15, D_Boy via D.gnu <d.gnu@puremagic.com> wrote: > > On Thursday, 23 May 2019 at 17:39:32 UTC, Iain Buclaw wrote: > > And what happens when you compile with -static-libphobos? > > > > This confirms whether you are indeed linking against the wrong library or not. > > gdc main.d -static -libphobos -o main > > /usr/bin/ld: cannot find -libphobos > collect2: error: ld returned 1 exit status Where did the space come from between static and -libphobos? :-) -- Iain |
Copyright © 1999-2021 by the D Language Foundation