leandromoreira / leandromoreira/ffmpeg-libav-tutorial

Cannot compile, using ffmpeg from sources

Open
#27 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question wontfix
Dominant language
C
Stars
11k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Hello, I'm using Ubuntu 18.04, did a clean install in a virtual machine. I downloaded libvpx from sources, compiled and installed without any problems.
Then I downloaded ffmpeg source (from git, from git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg), and compiled it (passing --enable-libvpx to it), make compiled without any issues, and did a make install.

When I try to make the 0_hello_world.c, make gives me the following error:
(you can check the output with a better looking text at https://pastebin.com/wPKY99ue )

mkdir build
gcc -g -Wall -o build/hello_world -lavformat -lavcodec -lswscale -lavutil -lz 0_hello_world.c
&& ./build/hello_world small_bunny_1080p_60fps.mp4`
0_hello_world.c: In function ‘main’:
0_hello_world.c:35:3: warning: ‘av_register_all’ is deprecated [-Wdeprecated-declarations]
av_register_all();
^~~~~~~~~~~~~~~
In file included from 0_hello_world.c:15:0:
/usr/local/include/libavformat/avformat.h:2033:6: note: declared here
void av_register_all(void);
^~~~~~~~~~~~~~~
/tmp/ccbsfyh8.o: In function 'av_make_error_string':
/usr/local/include/libavutil/error.h:111: undefined reference to 'av_strerror'
/tmp/ccbsfyh8.o: In function 'main':
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:35: undefined reference to 'av_register_all'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:40: undefined reference to 'avformat_alloc_context'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:54: undefined reference to 'avformat_open_input'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:73: undefined reference to 'avformat_find_stream_info'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:103: undefined reference to 'avcodec_find_decoder'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:125: undefined reference to 'avcodec_alloc_context3'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:134: undefined reference to 'avcodec_parameters_to_context'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:142: undefined reference to 'avcodec_open2'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:149: undefined reference to 'av_frame_alloc'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:156: undefined reference to 'av_packet_alloc'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:180: undefined reference to 'av_packet_unref'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:168: undefined reference to 'av_read_frame'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:185: undefined reference to 'avformat_close_input'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:186: undefined reference to 'avformat_free_context'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:187: undefined reference to 'av_packet_free'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:188: undefined reference to 'av_frame_free'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:189: undefined reference to 'avcodec_free_context'
/tmp/ccbsfyh8.o: In function 'decode_packet':
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:207: undefined reference to 'avcodec_send_packet'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:218: undefined reference to 'avcodec_receive_frame'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:230: undefined reference to 'av_get_picture_type_char'
/home/xultz/libav/ffmpeg-libav-tutorial/0_hello_world.c:242: undefined reference to 'av_frame_unref'
collect2: error: ld returned 1 exit status
Makefile:4: recipe for target 'hello_world' failed
make: *** [hello_world] Error 1

I took a look at pkg-config outputs from --libs and --cflags for some libs (lib libavformat, libavutil, etc) and I changed the gcc line on the Makefile to the following, but I couldn't see any changes on the make output:
gcc -g -Wall -I/usr/local/include -o build/hello_world -L/usr/local/lib -lavformat -lavcodec -lswscale -lavutil -lz -lvpx -lm -lswresample -pthread 0_hello_world.c

What else can I do in order to compile the code?

Thank you in advance for any help!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with Makefile and 0_hello_world.c on the reported Ubuntu setup, then compare the Makefile gcc command with the shown pkg-config flags. Done means the hello_world target compiles and runs against the locally installed FFmpeg libraries.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
audio-video-rtc
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.