digitalmars.D - Linking with gl3n can't find reference to _Dmodule_ref
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (78/78) Aug 25 2013 I'm starting a geometry module (fixed dimensional linear algebra)
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (2/2) Aug 25 2013 Note that problem occurs both in DMD versions 2.063.2 and in git
- David (4/4) Aug 25 2013 I can't reproduce this.
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (2/9) Aug 27 2013 Ok. Thx. I'll do that for now.
- David Nadlinger (5/7) Aug 25 2013 Did you (re)build libgl3n with the exact DMD version you a trying
I'm starting a geometry module (fixed dimensional linear algebra) similar to Boost.Geometry. I want these structures to have tight integration with OpenGL wrappers. I've built and installed gl3n and thought it would be a good base to start with. But when I try to link my sample application pragma(lib, "gl3n"); import gl3n.linalg; import std.stdio; import std.algorithm; void main(string args[]) { writeln(vec2(2, 3).x); writeln(vec2(2, 3)); writeln(cross(vec3(2, 3, 4), vec3(4, 3, 2))); writeln(dot(vec3(2, 3, 4), vec3(4, 3, 2))); writeln(vec3(2, 3, 4)); } I get the linking error /home/per/opt/x86_64-unknown-linux-gnu/dmd/bin/dmd -debug -gc -unittest -D -Dd/home/per/.emacs.d/auto-builds/dmd/Debug-Boundscheck-Unittest/h me/per/Work/cognia/ -w ~/Work/cognia/geometry.d -of/home/per/.emacs.d/auto-builds/dmd/Debug-Boundscheck-Unittest/home/per/Work/cognia/geometry /home/per/opt/x86_64-unknown-linux-gnu/dmd/bin/../lib/libgl3n.a(util.o): In function `no symbol': gl3n/util.d:(.text+0x6): undefined reference to `_Dmodule_ref' /home/per/opt/x86_64-unknown-linux-gnu/dmd/bin/../lib/libgl3n.a(linalg.o): In function `no symbol': gl3n/linalg.d:(.text+0x6): undefined reference to `_Dmodule_ref' /home/per/opt/x86_64-unknown-linux-gnu/dmd/bin/../lib/libgl3n.a(plane.o): In function `no symbol': gl3n/plane.d:(.text+0x6): undefined reference to `_Dmodule_ref' /home/per/opt/x86_64-unknown-linux-gnu/dmd/bin/../lib/libgl3n.a(plane.o): In function `_D4gl3n5plane13__T6PlaneTTfZ6PlaneT8opEqualsMxFNaNbNfS4gl3n5plane13__T6PlaneTTfZ6PlaneTZb': gl3n/plane.d:(.text._D4gl3n5plane13__T6PlaneTTfZ6PlaneT8opEqualsMxFNaNbNfS4gl3n5plane13__T6Plane TfZ6PlaneTZb+0x51): undefined reference to `_D4gl3n6linalg16__T6VectorTfVi3Z6Vector53__T8opEqualsTxS4gl3n6linalg16__T6VectorTfVi3Z6VectorZ8opEqualsMxFNaNbNfxS4gl3n6linalg16__T6VectorTfVi3Z6VectorZb' /home/per/opt/x86_64-unknown-linux-gnu/dmd/bin/../lib/libgl3n.a(math.o): In function `no symbol': gl3n/math.d:(.text+0x6): undefined reference to `_Dmodule_ref' collect2: error: ld returned 1 exit status --- errorlevel 1 I know DMD finds the libgl3n.a because otherwise it complains about hundreds of missing symbols. It is however strange that a single gl3n-symbol is missing. Maybe there's a bug gl3n. I've tried adding extern (C) void* _Dmodule_ref = null; the line as indicated in other threads but then again I get /home/per/opt/x86_64-unknown-linux-gnu/dmd/bin/dmd -debug -gc -unittest -D -Dd/home/per/.emacs.d/auto-builds/dmd/Debug-Boundscheck-Unittest/h me/per/Work/cognia/ -w ~/Work/cognia/geometry.d -of/home/per/.emacs.d/auto-builds/dmd/Debug-Boundscheck-Unittest/home/per/Work/cognia/geometry /usr/bin/ld: _Dmodule_ref: TLS definition in /home/per/.emacs.d/auto-builds/dmd/Debug-Boundscheck-Unittest/home/per/Wo k/cognia/geometry.o section .tbss mismatches non-TLS reference in /home/per/opt/x86_64-unknown-linux-gnu/dmd/bin/../lib/libgl3n.a(util.o) /home/per/opt/x86_64-unknown-linux-gnu/dmd/bin/../lib/libgl3n.a: could not read symbols: Bad value collect2: error: ld returned 1 exit status --- errorlevel 1 I can't understand what the meaning of _Dmodule_ref even not after having read about it in other threads. Some say it has to do with linking to C libraries but gl3n doesn't use C libraries. The error is removed when I remove pragma(lib, "gl3n"); along with the import and uses gl3n structures (of course) so the symbols _Dmodule_ref is referenced from libgl3n.a What is wrong? Thx, Per Nordlöw
Aug 25 2013
Note that problem occurs both in DMD versions 2.063.2 and in git master.
Aug 25 2013
I can't reproduce this. But I recommend you to use gl3n as a submodule (if you use git) or include the sources directly and add the files to your build-system. That makes distributing easier and gets hopefully rid of this error.
Aug 25 2013
On Sunday, 25 August 2013 at 10:36:19 UTC, David wrote:I can't reproduce this. But I recommend you to use gl3n as a submodule (if you use git) or include the sources directly and add the files to your build-system. That makes distributing easier and gets hopefully rid of this error.Ok. Thx. I'll do that for now.
Aug 27 2013
On Sunday, 25 August 2013 at 10:12:48 UTC, Nordlöw wrote:so the symbols _Dmodule_ref is referenced from libgl3n.a What is wrong?Did you (re)build libgl3n with the exact DMD version you a trying to use it from? The binaries produced by different releases of the various compilers around are not ABI-compatible. David
Aug 25 2013