0

I downloaded the ffmpeg from git, and make the libs by sources. Created main.c as below and put the ffmpeg libs in the same folder as main.c, (my system is ubuntu 15.10, gcc version 5.2.1)

#include <stdio.h>
void av_register_all(void);
int main() {
    printf("abc\n");
    av_register_all();
    return 0;
}

After I issued gcc main.c -L. -lavformat -lswscale -lavcodec -lswscale -lavutil -lavdevice -lavfilter, I got a lot of (nearly 1000) undefined reference errors:

...
/home/arton/sources/ffmpeg/libavcodec/vorbisdec.c:868: undefined reference to `atan'
/home/arton/sources/ffmpeg/libavcodec/vorbisdec.c:868: undefined reference to `atan'
/home/arton/sources/ffmpeg/libavcodec/vorbisdec.c:869: undefined reference to `atan'
/home/arton/sources/ffmpeg/libavcodec/vorbisdec.c:869: undefined reference to `atan'
/home/arton/sources/ffmpeg/libavcodec/vorbisdec.c:869: undefined reference to `floor'
...

/home/arton/sources is where the ffmpeg sources at, I have no idea why it report the sources path of ffmpeg and why the link fails. Any hint is appreciated. Thanks!

Arton
  • 443
  • 1
  • 6
  • 15

1 Answers1

1

atan and floor are included in lm.

Do you link with lm?

You might want to read this.

Community
  • 1
  • 1
Martin
  • 3,960
  • 7
  • 43
  • 43
  • Thanks! I added -lm -lpthread -lswresample, and the link successes. I was confused by the report of sources path. So I did not try to check missing libraries. – Arton Jan 30 '16 at 05:16
  • But I am curious about why I don't need -lm to build (with gcc) a hello world program which contains atan(0.5). – Arton Jan 30 '16 at 05:26
  • @Arton Cannot tell without looking at your program/compile command. Consider asking another question if you don't find your answer in the numerous `lm` content already available. – Martin Jan 30 '16 at 14:22