D.gnu - stdout does not work in GDC
- D_Boy (12/12) May 20 2019 I am following Ali Çehreli's book. It says that stdout.write()
- D_Boy (3/15) May 20 2019 Update: the hello world program works fine. Problem appears when
- Iain Buclaw (19/39) May 20 2019 $ gdc-8 test.d -o shared
- D_Boy (40/84) May 23 2019 Hi! Thanks for your reply!
- Iain Buclaw (5/93) May 23 2019 And what happens when you compile with -static-libphobos?
- D_Boy (4/7) May 27 2019 gdc main.d -static -libphobos -o main
- Iain Buclaw (4/12) May 27 2019 Where did the space come from between static and -libphobos? :-)
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
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
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:$ 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. -- IainI 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
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: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.On Monday, 20 May 2019 at 08:01:01 UTC, D_Boy wrote:$ 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.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 23 2019
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:And what happens when you compile with -static-libphobos? This confirms whether you are indeed linking against the wrong library or not. -- IainOn Mon, 20 May 2019 at 12:50, D_Boy via D.gnu <d.gnu puremagic.com> wrote: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.On Monday, 20 May 2019 at 08:01:01 UTC, D_Boy wrote:$ 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.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 23 2019
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
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:Where did the space come from between static and -libphobos? :-) -- IainAnd 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