www.digitalmars.com         C & C++   DMDScript  

D.gnu - Installed with sudo apt-get install gdc in Ubuntu 18.04 - Can't

reply Stefanos Baziotis <sdi1600105 di.uoa.gr> writes:
Hello everyone,

I just installed GDC with sudo apt-get install gdc and I can't 
compile a simple hello world program. I get e.g. static foreach 
errors:

/usr/local/include/d/core/internal/hash.d:333:16: error: basic 
type expected, not foreach
          static foreach (i; 0 .. T.sizeof / size_t.sizeof)

Any idea? Before about a month I used to compile hundeds of lines 
but I don't remember how..

Thanks,
Stefanos
Aug 06 2019
next sibling parent reply Boris Carvajal <boris2.9 gmail.com> writes:
On Tuesday, 6 August 2019 at 11:45:50 UTC, Stefanos Baziotis 
wrote:
 Hello everyone,

 I just installed GDC with sudo apt-get install gdc and I can't 
 compile a simple hello world program. I get e.g. static foreach 
 errors:

 /usr/local/include/d/core/internal/hash.d:333:16: error: basic 
 type expected, not foreach
          static foreach (i; 0 .. T.sizeof / size_t.sizeof)

 Any idea? Before about a month I used to compile hundeds of 
 lines but I don't remember how..

 Thanks,
 Stefanos
At least gdc from gcc9 doesn't support static foreach, probably it's reading imports from other d compiler install.
Aug 06 2019
parent reply Stefanos Baziotis <sdi1600105 di.uoa.gr> writes:
On Tuesday, 6 August 2019 at 12:02:05 UTC, Boris Carvajal wrote:
 At least gdc from gcc9 doesn't support static foreach, probably 
 it's reading imports from other d compiler install.
Yes it seems so. I installed LDC from source recently, maybe that made the conflict. I don't know how to fix it but thanks anyway. Stefanos
Aug 06 2019
parent reply Johannes Pfau <nospam example.com> writes:
Am Tue, 06 Aug 2019 12:22:56 +0000 schrieb Stefanos Baziotis:

 On Tuesday, 6 August 2019 at 12:02:05 UTC, Boris Carvajal wrote:
 At least gdc from gcc9 doesn't support static foreach, probably it's
 reading imports from other d compiler install.
Yes it seems so. I installed LDC from source recently, maybe that made the conflict. I don't know how to fix it but thanks anyway. Stefanos
gdc includes everything in /usr/include/d automatically. The assumption is that distributions will only install global D files there which are compiler-independent, just like in /usr/include. Unfortunately dmd and/or ldc still seem to install their druntime/phobos D files there, so you likely need to remove these files from /usr/include/ d (the best way is to use the uninstall procedure matching the way you installed it). -- Johannes
Aug 06 2019
parent reply Stefanos Baziotis <sdi1600105 di.uoa.gr> writes:
On Tuesday, 6 August 2019 at 16:38:56 UTC, Johannes Pfau wrote:
 gdc includes everything in /usr/include/d automatically. The 
 assumption is that distributions will only install global D 
 files there which are compiler-independent, just like in 
 /usr/include.

 Unfortunately dmd and/or ldc still seem to install their 
 druntime/phobos D files there, so you likely need to remove 
 these files from /usr/include/ d (the best way is to use the 
 uninstall procedure matching the way you installed it).
The problem is that the way I installed them is by building LDC with ninja. And I don't know how this can be reverted. I've searched online, but apparently if something is installed without a package manager, then "Good Luck". :P
Aug 06 2019
parent reply Iain Buclaw <ibuclaw gdcproject.org> writes:
On Tue, 6 Aug 2019 at 19:15, Stefanos Baziotis via D.gnu
<d.gnu puremagic.com> wrote:
 On Tuesday, 6 August 2019 at 16:38:56 UTC, Johannes Pfau wrote:
 gdc includes everything in /usr/include/d automatically. The
 assumption is that distributions will only install global D
 files there which are compiler-independent, just like in
 /usr/include.

 Unfortunately dmd and/or ldc still seem to install their
 druntime/phobos D files there, so you likely need to remove
 these files from /usr/include/ d (the best way is to use the
 uninstall procedure matching the way you installed it).
The problem is that the way I installed them is by building LDC with ninja. And I don't know how this can be reverted. I've searched online, but apparently if something is installed without a package manager, then "Good Luck". :P
Maybe ldc should be fixed to install compiler-specific modules inside a compiler-specific directory? There may be a configure switch to control that. -- Iain
Aug 06 2019
parent Stefanos Baziotis <sdi1600105 di.uoa.gr> writes:
On Wednesday, 7 August 2019 at 05:54:58 UTC, Iain Buclaw wrote:
 Maybe ldc should be fixed to install compiler-specific modules 
 inside a compiler-specific directory?  There may be a configure 
 switch to control that.
It seems there is. I was not aware of the problem when installing so I did not configure it. For anyone else trying to install LDC from source, in the CMake cmdline, with the INCLUDE_INSTALL_DIR one can set where phobos and druntime will be installed [1]. [1] https://wiki.dlang.org/Building_LDC_from_source#Useful_CMake_variables
Aug 07 2019
prev sibling parent reply James Blachly <james.blachly gmail.com> writes:
On 8/6/19 7:45 AM, Stefanos Baziotis wrote:
 Hello everyone,
 
 I just installed GDC with sudo apt-get install gdc and I can't compile a 
 simple hello world program. I get e.g. static foreach errors:
I also have just installed GDC via apt on Ubuntu18 and cannot compile my codebase (via dub build --compiler=gdc). However, I am getting a different error related to symbols: ../intervaltree/.dub/build/library-release-debug-linux.posix-x86_64-gdc_2068-CAF4B0AA644EFF0EF2E4C805B972A804/libinterval ree.a:(minfo+0x20): multiple definition of `_D12intervaltree7avltree11__moduleRefZ' /tmp/ccNVyy2Z.o:(minfo+0xe0): first defined here ../intervaltree/.dub/build/library-release-debug-linux.posix-x86_64-gdc_2068-CAF4B0AA644EFF0EF2E4C805B972A804/libinterval ree.a:(.data+0x80): multiple definition of `_D12intervaltree7avltree12__ModuleInfoZ' /tmp/ccNVyy2Z.o:(.data+0x2c0): first defined here collect2: error: ld returned 1 exit status gdc failed with exit code 1. This codebase compiles fine with dmd2 and ldc2, neither of which is installed at the system level. This is a clean VM. Since I have version() sprinkled all throughout the code, and the error relates to a symbol that should not even be present (avltree) , I am wondering if GDC is correctly honoring the version() markers in the code. Why else would the avltree symbol appear if it is 100% version()ed out?
Aug 18 2019
parent James Blachly <james.blachly gmail.com> writes:
On 8/18/19 11:20 AM, James Blachly wrote:
 ../intervaltree/.dub/build/library-release-debug-linux.posix-x86_64-gdc_2068-CAF4B0AA644EFF0EF2E4C805B972A804/libinterval
ree.a:(minfo+0x20): 
 multiple definition of `_D12intervaltree7avltree11__moduleRefZ'
 /tmp/ccNVyy2Z.o:(minfo+0xe0): first defined here
 ../intervaltree/.dub/build/library-release-debug-linux.posix-x86_64-gdc_2068-CAF4B0AA644EFF0EF2E4C805B972A804/libinterval
ree.a:(.data+0x80): 
 multiple definition of `_D12intervaltree7avltree12__ModuleInfoZ'
 /tmp/ccNVyy2Z.o:(.data+0x2c0): first defined here
 collect2: error: ld returned 1 exit status
 gdc failed with exit code 1.
Problem solved -- I had identical module file under a different path; DMD and LDC merged them into a single symbol/code, while GDC generated and emitted them separately, resulting in a linker error. This also means I have successfully compiled with GDC for the first time. Glad that it was painlessly available via apt-get.
Aug 18 2019