[Vorbis] libvorbisfile dynamic linkage with pkg-config - inter-library dependencies?

Richard Ash richard at audacityteam.org
Sat Aug 9 15:04:03 PDT 2014


Audacity is preparing to release version 2.0.6 shortly, so I have been
doing numerous test builds. Since the last Audacity release, my
development system (Gentoo Linux) has updated to libvorbis-1.3.4 and
libogg-1.3.1.

As a result (I think) of this, I now get link errors when
trying to compile Audacity against the system copies of libogg and
libvorbis (standard dynamic linkage to the system libraries). There
has not been significant change to the Audacity calling code since
this was last working. The problem seems to be that 
 pkg-config --libs --print-errors "vorbisfile"
outputs
 -lvorbisfile
but when I try to link Audacity with only -lvorbisfile on the linker
command line, the link fails with

/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld:
export/audacity-ExportOGG.o: undefined reference to symbol
'vorbis_block_init'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld:
note: 'vorbis_block_init' is definedExportOGG.o in
DSO /usr/lib64/libvorbis.so.0 so try adding it to the linker command 
line
/usr/lib64/libvorbis.so.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make[2]: *** [audacity] Error 1

vorbis_block_init() is called from ExportOGG.cpp, although that file
doesn't #include vorbis/codec.h - the only include from libvorbis is
#include <vorbis/vorbisenc.h>, which presumably brings the necessary
headers in indirectly?

The only solution I have found is to explicitly ask pkg-config for the
dependent libraries (libvorbis and libogg) when calling pkg-config, so
do
 pkg-config --libs --print-errors "vorbisfile vorbis ogg"
in order to get
 -lvorbisfile -lvorbis -logg
which then links correctly. This does not seem (to me) to be the
intended behaviour of pkg-config, and it certainly isn't how it used to
happen the last time I had to work on this, but I'm not 100% sure what
has changed in the mean time!

Is there any documentation on the "correct" way to link to the
higher-level Vorbis APIs using pkg-config? Is this intended, or an
accidental change?

Richard


More information about the Vorbis mailing list