Undefined reference to ' av_close_input_file ' cause analysis

Source: Internet
Author: User

This is the problem of using libdlna0.2.4 and ffmpeg2.4.2 collocation

The following is my own analysis of the reasons for the error, the content is relatively long, writing is also more casual. If you're just looking for a solution, I'll summarize it here:

ffmpeg2.4.2 default is not to support the Av_close_input_file function, replaced by the Avformat_close_input function


The solution is to use the ffmpeg2.2.9 version (a longer version has not been tested),

Or insist on using the ffmpeg2.4.2 version, just

A little bit of content in the./ffmpeg-2.4.2/libavformat/version.h file is modified:

-------------------------------------------

#defineLIBAVFORMAT_VERSION_MAJOR 56

#define Libavformat_version_minor 4

#define LIBAVFORMAT_VERSION_MICRO 101

-------------------------------------------

Modified into:

#defineLIBAVFORMAT_VERSION_MAJOR 55

Here's how to start my analysis process:

--------------------------------------------------------------------------------------------------------------- -----


Problems encountered when compiling the Libdlna

Error message to execute make:

--------------------------------------------------------------

...

GCC test-libdlna.c-w-wall-wno-unused-but-set-variable-d_largefile_source-d_file_offset_bits=64-d_reentrant-o3- Isrc-lsrc-ldlna-lavformat-pthread-lavcodec-lswresample-lavutil-lrt-lm-o Test-libdlna

src/libdlna.so:undefined reference to ' Av_close_input_file '

src/libdlna.so:undefined reference to ' Av_find_stream_info '

collect2:ldreturned 1 Exit status

Make: ***[test-libdlna] Error 1

--------------------------------------------------------------

Let's see how the libdlna.so is compiled:

Analyze Src/makefile Files:

----------------------------------------------------

Libname = Libdlna

Libname_shared =${libname}.so

Lib_shared:lib_shared_info_pre $ (LOBJS) Lib_shared_info_post

$ (CC)-shared-wl,-soname,$ (libname_major) $ (LOBJS) \

$ (ldflags) $ (extralibs)-o$ (libname_version)

$ (LN)-SF $ (libname_version) $ (libname_major)

$ (LN)-SF $ (libname_major) $ (libname_shared)

----------------------------------------------------

corresponding to the output information:

--------------------------------------------------------------------------------------------------------------- ------------------------------

gcc-shared-wl,-soname,libdlna.so.0 profiles.lo containers.lo Image_jpeg.lo image_png.loaudio_aac.lo Audio_ac3.lo Audio_amr.lo audio_atrac3.lo audio_g726.loaudio_lpcm.lo audio_mp2.lo audio_mp3.lo audio_wma.lo av_mpeg1.lo av_ Mpeg2.loav_mpeg4_part2.lo Av_mpeg4_part10.lo Av_wmv9.lo upnp_dms.lo \

-pthread-lavformat-lavcodec-lswresample-lavutil-lrt-lm-o libdlna.so.0.2.4

ln-sflibdlna.so.0.2.4 libdlna.so.0

LN-SF libdlna.so.0libdlna.so

--------------------------------------------------------------------------------------------------------------- ------------------------------

Want to know which library the av_close_input_file was defined in before Libdlna.so appeared,

Then first look at the next function av_close_input_file where it is used:

------------------------------------------------------------

$ GREP-RN "Av_close_input_file"./src/

Binary file./src/libdlna.so Matches

Binary File./src/profiles.lo Matches

Binary FILE./SRC/PROFILES.O Matches

Binary file./src/libdlna.so.0.2.4 Matches

./src/profiles.c:337:av_close_input_file (CTX);

Binary FILE./SRC/LIBDLNA.A Matches

Binary file./src/libdlna.so.0 Matches

------------------------------------------------------------

You can't see directly where it is, but you can see that it was called by the profiles.c file.

./src/profiles.c

------------------------------------------------------------

#include <stdlib.h>

#include <string.h>

24

#include "Dlna_internals.h"

#include "Profiles.h"

#include "Containers.h"

...

337 Av_close_input_file (CTX);

338 free (codecs);

339 return profile;

340}

...

------------------------------------------------------------

Look at the bottom of the file:

./src/profiles.h

------------------------------------------------------------

#include <libavcodec/avcodec.h>

#include <libavformat/avformat.h>

27

#include "Dlna_internals.h"

#include "Containers.h"

------------------------------------------------------------

See here, you should be able to guess that av_close_input_file is defined in avcodec.h or avformat.h (generated when compiling the installation ffmpeg)

With grep, you can see that it's in avformat.h.

/usr/local/include/libavformat/avformat.h:

----------------------------------------------------------------------

2173 #ifFF_API_CLOSE_INPUT_FILE

2174/**

2175 * @deprecated use Avformat_close_input ()

2176 * Close a media file (but not its codecs).

2177 *

2178 * @param s media file handle

2179 */

2180attribute_deprecated

2181 void Av_close_input_file (Avformatcontext *s);

2182 #endif

---------------------------------------------------------------------

is also just a declaration of function av_close_input_file, not a definition

Baidu for a moment to know that the general function is defined in the library:

To view the functions called by the library Avformat with the NM command:

-----------------------------------------------------

$ nm libavformat.a |grep "Close_input"

U Avformat_close_input

U Avformat_close_input

U Avformat_close_input

U Avformat_close_input

U Avformat_close_input

U Avformat_close_input

U Avformat_close_input

U Avformat_close_input

0000c710 Tavformat_close_input

----------------------------------------------------

Can be found, and there is no av_close_input_file, only avformat_close_input.

Does compiling ffmpeg not compile the function av_close_input_file into the library?


All right...

We're going back to the FFmpeg source directory (ffmpeg-2.4.2).

--------------------------------------------------------------------------------------------------------------- ------

$ GREP-RN "Av_close_input_file"./

./libavformat/avformat.h:2181:voidav_close_input_file (Avformatcontext *s);

./libavformat/utils.c:3534:voidav_close_input_file (Avformatcontext *s)

./doc/apichanges:1108:deprecate Av_close_input_file () Andav_close_input_stream ().

--------------------------------------------------------------------------------------------------------------- ------

It seems that Av_close_input_file's function statement should be in the./libavformat/utils.c file.

------------------------------------------------------------------------------

3533 #ifFF_API_CLOSE_INPUT_FILE

3534 voidav_close_input_file (Avformatcontext *s)

3535 {

3536 avformat_close_input (&s);

3537}

3538 #endif

------------------------------------------------------------------------------

There is also a file that contains the Av_close_input_file:

.../ffmpeg-2.4.2/doc/apichanges

----------------------------------------------------------

1106 2011-12-12-8BC7FE4/5266045-LAVF 53.25.0/53.17.0

1107 Add Avformat_close_input ().

1108 deprecate Av_close_input_file () and Av_close_input_stream ().

----------------------------------------------------------

Did Av_close_input_file () and Av_close_input_stream () have been abandoned ...

be replaced with Avformat_close_input () ......


Look at what libraries the LIBAVFORMAT.A library consists of:

.../ffmpeg-2.4.2/libavformat/makefile

----------------------------------------------------------

3 NAME = Avformat

4

5 HEADERS = avformat.h \

6 avio.h \

7 version.h \

8

9 Objs = allformats.o \

Ten AVIO.O \

One AVIOBUF.O \

CUTILS.O \

DUMP.O \

FORMAT.O \

ID3V1.O \

ID3V2.O \

METADATA.O \

MUX.O \

OPTIONS.O \

&nbs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.