0

I have two projects. Project "vDevice" compiles into "libvDevice.so". This library is then used by the other project "videoViewer", which compiles into a binary "app_videoViewer". These were both working fine before I added a call to avdevice_reigster_all() in one of vDevice's files.

vDevice.so compiles and links with no errors. In the makefile I have -L${FFMPEG_PATH} (where all the libav*.a files are located), and -l avformat, avcodec, avutil, asound, avdevice, and bz2 (in that order).

When I try to make videoViewer now, I get this error:

Linking application app_videoViewer ...
/path/to/lib/libvDevice.so: undefined reference to `avdevice_register_all'
collect2: error: ld returned 1 exit status

For videoViewer I added the same things to the makefile, linking to avformat, avcodec, avutil, asound, avdevice, and bz2, all before vDevice... what am I missing?

user812786
  • 4,302
  • 5
  • 38
  • 50
  • 1
    Missing symbols are searched for in libraries when the `-llibrary` flag is seen. You need the objects *before* the libraries. – Etan Reisner Nov 12 '15 at 18:12
  • Meaning put -`lvDevice` before `-lavformat`, etc.? For some reason I thought it was supposed to be the other way around.. Switching the order worked though! Would you mind putting this as an answer? – user812786 Nov 12 '15 at 18:32
  • 1
    This is essentially a "duplicate" of http://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc (and a number of other questions as well). – Etan Reisner Nov 12 '15 at 18:59

0 Answers0