Hi, I found some inconsistency to the dmd compiler. If I want to compile this simple program: import std.stdio; import gtk.Main; /* -I/usr/local/include/d/gtkd-3 */ void main(string[] args) { // Prints "Hello World" string in console writeln("Hello World!"); // Lets the user press <Return> before program returns stdin.readln(); return; } I get an error using gdc, but not with dmd. The GtkD library must be installed, though. My .so files are at a default location, the header files are at a seperate location. Now the output of both: ~$ dmd main.d -I/usr/local/include/d/gtkd-3 -L-lgtkd-3 ~$ ./main Hello World! ~$ gdc main.d -I/usr/local/include/d/gtkd-3 -lgtkd-3 ~$ ./a.out Fatal Error while loading '/usr/lib/x86_64-linux-gnu/libphobos2.so.0.71': The module 'std.array' is already defined in './a.out'. It is this line, which causes the error: import gtk.Main; /* -I/usr/local/include/d/gtkd-3 */ If I delete this line, a.out does not throw an error. (But I cant use the GtkD library then...) Some more information: ~$ gdc --version gdc (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609 ~$ ld -v GNU ld (GNU Binutils for Ubuntu) 2.26.1 ~$ dmd -v DMD64 D Compiler v2.071.1
(In reply to Chalix from comment #0) > ~$ gdc main.d -I/usr/local/include/d/gtkd-3 -lgtkd-3 > ~$ ./a.out > Fatal Error while loading '/usr/lib/x86_64-linux-gnu/libphobos2.so.0.71': > The module 'std.array' is already defined in './a.out'. > > My guess would be that gtkd was built with dmd, because this is not the phobos library used by gdc.
Does this mean, I can't include libraries in my gdc project, which are complied with dmd, because they use different implementations of the same standard library? Or did I do something wrong, so that I could fix this? My solution for now is, not to use gdc... But this seems not very satisfying. My understanding of a compiler is, that I can use them independent of each other.
(In reply to Chalix from comment #2) > Does this mean, I can't include libraries in my gdc project, which are > complied with dmd, because they use different implementations of the same > standard library? > > Or did I do something wrong, so that I could fix this? > Well, you'd need a version of gtkd library built with gdc, and another with dmd. DMD's install script is aware of both dmd and gdc, and will install them in separate environments in very much the same way as python's virtualenv. https://dlang.org/install.sh If you need separation, this would be the best way to do it. Rather than installing libraries and interface files in /usr/local.
> Does this mean, I can't include libraries in my gdc project, which are complied > with dmd, because they use different implementations of the same standard > library? [...] My understanding of a compiler is, that I can use them > independent of each other. Ideally that should be that case, but right now none of the compilers are ABI compatible. I hope we'll solve this problem at some point, but as long as the DMD developers are not interested in this topic it's unlikely the GDC team can solve this problem with our limited resources. So for now you'll have to compile all your dependencies with the same compiler. DUB can automatically handle this, though it is more difficult when using gtkD as a shared library.
(In reply to Johannes Pfau from comment #5) > Ideally that should be that case, but right now none of the compilers are > ABI compatible. I hope we'll solve this problem at some point Thank you, Johannes, that was exactly what I wanted to know :) Would be great, if you could get the compilers ABI compatible. This also makes it easier to detect compiler bugs, because you can test against another compiler with a different implementation easier. Just keep up communication with the dmd team :) For now, I can live with the two separate libraries. And for DUB, I don't understand the magic behind it, and it also didn't work the first time, so I like to link my projects the conventional way^^
This is not really a gdc bug, as we only ever use the system ABI, I would instead extend the invitation for ldc/dmd to compatible with gdc. The other way around is not possible.