1

I follow the ffmpeg tuorial, and install ffmpeg via ppa

But when I compiled the tuorial02.c, I got gcc error:

/usr/bin/ld: /opt/ffmpeg/lib//libavcodec.a(libvorbisenc.o): undefined reference to symbol 'vorbis_encode_setup_vbr'

//usr/lib/x86_64-linux-gnu/libvorbisenc.so.2: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

My compile command is:

gcc -I /opt/ffmpeg/include/ -L /opt/ffmpeg/lib/  -o tutorial02 tutorial02.c -lavformat -lavcodec -lswscale `sdl-config --cflags --libs`  -lpthread -lz -lm -ldl

I have searched the reason for hours. I can't solve this. Can anyone help me?

Added I have add -lvorbisenc to the end. the error is lib not found. and libvorivisenc2 has been install. so this question is not a duplicate of Strange linking error: DSO missing from command line

And My OS is Linux mint 17.3

Community
  • 1
  • 1
ldkxingzhe
  • 21
  • 7
  • Try adding `-lvorbisenc` to the end of your compiling/linking command. It looks like the linker is complaining that it can't find `vorbis_encode_setup_vbr`, which is defined in [libvorbisenc](https://xiph.org/vorbis/doc/vorbisenc/vorbis_encode_setup_vbr.html), which suggests you aren't linking to it. – Cornstalks May 08 '16 at 04:35
  • Possible duplicate of [Strange linking error: DSO missing from command line](http://stackoverflow.com/questions/19901934/strange-linking-error-dso-missing-from-command-line) – Cornstalks May 08 '16 at 04:35
  • @Cornstalks when I add `-lvorbisenc` to the end of my command. and got error /usr/bin/ld: **cannot find -lvorbisenc**. but package libvorbisenc2 has been installed. And my os is Linux mint 17.3 – ldkxingzhe May 08 '16 at 04:45

1 Answers1

1

The error is telling you that the static library libavcodec.a references symbols from libvorbisenc but libvorbisenc isn't explicitly in your link command (though it did find a good candidate from another shared library in the link command). You'll need to add -lvorbisenc or $(pkg-config --libs vorbisenc) explicitly to your command line.

(Older versions of binutils would let you bring in shared libraries implicitly in this situation; however, newer versions of binutils are stricter.)

Daniel Schepler
  • 3,043
  • 14
  • 20
  • yeah, It may be the reason. but when add `-lvorbisenc`, the error is can't find libvorbisenc. I also can't find the package. when I run `(pkg-config --libs vorbisenc`, the error is: Package vorbisenc was not found in the pkg-config search path. Perhaps you should add the directory containing `vorbisenc.pc' to the PKG_CONFIG_PATH environment variable No package 'vorbisenc' found. and my OS is Linux Mint 17.3 . Thanks – ldkxingzhe May 08 '16 at 04:52
  • On my Debian system, `libvorbis-dev` package contains `vorbisenc.pc` so I'd check if `libvorbis-dev` is installed. – Daniel Schepler May 08 '16 at 05:27
  • Thank you!! It's libvorbis-dev package contains. but unfortunately, I think i commad is wrong, There are a lot error, like: /libavcodec.a(libmp3lame.o): In function `mp3lame_encode_init': (.text.unlikely+0x169): undefined reference to `lame_init_params' . the ffmpeg's lib is static lib. is that wrong? Sorry to confuse you. – ldkxingzhe May 08 '16 at 05:48
  • ffmpeg being a static lib isn't wrong. However, precisely what you're running into is one of the big disadvantages of static libs vs shared libs: with static libs you have to give all the transitive dependencies explicitly, whereas with shared libs all you have to specify is the libraries your program uses explicitly. In this case, you'd have to track down the LAME library (`apt-cache search lame` to find `libmp3lame-dev` in my case), and so on for any other indirect dependencies from ffmpeg. – Daniel Schepler May 08 '16 at 06:20