www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Linker error (DSO missing)

reply Chris <wendlec tcd.ie> writes:
I keep getting this weird error with LDC. libogg is installed on 
my machine, I have it listed in the dub.json file under "libs", 
and it works fine when compiled with dmd (2.067.1), both release 
and debug.

Do I have to pass anything else?

[EROOR]
$ dub --build=release 
--compiler=../../D/ldc2-0.16.0-beta1/bin/ldc2
Performing "release" build using 
../../D/ldc2-0.16.0-beta1/bin/ldc2 for x86_64.
vibe-d 0.7.25: target for configuration "libevent" is up to date.
program ~master: building configuration "server64"...
/usr/bin/ld: /lib/linux/64bit/libsndfile.a(ogg.o): undefined 
reference to symbol 'ogg_stream_reset'
/usr/lib/x86_64-linux-gnu/libogg.so.0: error adding symbols: DSO 
missing from command line
collect2: error: ld returned 1 exit status
Error: /usr/bin/gcc failed with status: 1
../../D/ldc2-0.16.0-beta1/bin/ldc2 failed with exit code 1.
[END ERROR]
Oct 19 2015
next sibling parent Chris <wendlec tcd.ie> writes:
On Monday, 19 October 2015 at 14:30:47 UTC, Chris wrote:
 I keep getting this weird error with LDC. libogg is installed 
 on my machine, I have it listed in the dub.json file under 
 "libs", and it works fine when compiled with dmd (2.067.1), 
 both release and debug.

 Do I have to pass anything else?

 [EROOR]
 $ dub --build=release 
 --compiler=../../D/ldc2-0.16.0-beta1/bin/ldc2
 Performing "release" build using 
 ../../D/ldc2-0.16.0-beta1/bin/ldc2 for x86_64.
 vibe-d 0.7.25: target for configuration "libevent" is up to 
 date.
 program ~master: building configuration "server64"...
 /usr/bin/ld: /lib/linux/64bit/libsndfile.a(ogg.o): undefined 
 reference to symbol 'ogg_stream_reset'
 /usr/lib/x86_64-linux-gnu/libogg.so.0: error adding symbols: 
 DSO missing from command line
 collect2: error: ld returned 1 exit status
 Error: /usr/bin/gcc failed with status: 1
 ../../D/ldc2-0.16.0-beta1/bin/ldc2 failed with exit code 1.
 [END ERROR]
Recte: I get the same error with dmd in "--build=release" mode!
Oct 19 2015
prev sibling parent reply David Nadlinger via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> writes:
On 19 Oct 2015, at 16:30, Chris via digitalmars-d-ldc wrote:
 I keep getting this weird error with LDC. libogg is installed on my 
 machine, I have it listed in the dub.json file under "libs", and it 
 works fine when compiled with dmd (2.067.1), both release and debug.

 Do I have to pass anything else?
Make sure the linker command lists libogg *after* libsndfile (LDC -v shows you the command, same for DMD). To get some idea about what could be going on, you might want to add -Wl,--verbose to the gcc command used for linking. — David
Oct 19 2015
next sibling parent reply Chris <wendlec tcd.ie> writes:
On Monday, 19 October 2015 at 14:39:51 UTC, David Nadlinger wrote:
 On 19 Oct 2015, at 16:30, Chris via digitalmars-d-ldc wrote:
 I keep getting this weird error with LDC. libogg is installed 
 on my machine, I have it listed in the dub.json file under 
 "libs", and it works fine when compiled with dmd (2.067.1), 
 both release and debug.

 Do I have to pass anything else?
Make sure the linker command lists libogg *after* libsndfile (LDC -v shows you the command, same for DMD). To get some idea about what could be going on, you might want to add -Wl,--verbose to the gcc command used for linking. — David
Thanks for the confirmation that it might just be a case of the wrong order. I too think that it's a matter of ordering the libs correctly, however, I keep getting all sorts of linker errors when re-ordering the libs. Now I'll have to figure out which order is correct.
Oct 19 2015
parent Chris <wendlec tcd.ie> writes:
On Monday, 19 October 2015 at 14:52:43 UTC, Chris wrote:

On the other hand, why does it work with dmd in debug mode?
Oct 19 2015
prev sibling parent reply Chris <wendlec tcd.ie> writes:
On Monday, 19 October 2015 at 14:39:51 UTC, David Nadlinger wrote:

 Make sure the linker command lists libogg *after* libsndfile 
 (LDC -v shows you the command, same for DMD).
This did the trick. How are the libs ordered? I can see that the order of the libs in my dub.json file ("libs":["bla"]) is not the same as in the command that is generated. Does dub handle this or is it the compiler (checking for dependencies)? I had to change the order of -lportaudio and -ljack manually. -ljack was listed before -lportaudio, giving rise to linker errors, of course. This is not optimal, I shouldn't have to do that.
Oct 19 2015
parent reply David Nadlinger via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> writes:
On 19 Oct 2015, at 17:25, Chris via digitalmars-d-ldc wrote:
 This did the trick. How are the libs ordered? I can see that the order 
 of the libs in my dub.json file ("libs":["bla"]) is not the same as in 
 the command that is generated. Does dub handle this or is it the 
 compiler (checking for dependencies)?
LDC just passes the argument list through to the linker, as do the other compilers. Any intelligent ordering has to happen before that. — David
Oct 19 2015
parent Chris <wendlec tcd.ie> writes:
On Monday, 19 October 2015 at 18:14:42 UTC, David Nadlinger wrote:
 On 19 Oct 2015, at 17:25, Chris via digitalmars-d-ldc wrote:
 This did the trick. How are the libs ordered? I can see that 
 the order of the libs in my dub.json file ("libs":["bla"]) is 
 not the same as in the command that is generated. Does dub 
 handle this or is it the compiler (checking for dependencies)?
LDC just passes the argument list through to the linker, as do the other compilers. Any intelligent ordering has to happen before that. — David
Hm. Then I don't understand why the order is different from the one I give it. Maybe I'll have to use "lflags" instead of "libs" in my dub.json file. If it were an assoc array, it could happen that the order might change in memory, but it's a linear array, isn't it? "libs":["sndfile", "ogg", "etc..."],
Oct 19 2015