1

このようなプログラムを作りました。

  1 #include <stdio.h>
  2 #include <string.h>
  3 #include <stdlib.h>
  4 #include "libavformat/avformat.h"
  5 
  6 int main (int argc, char* argv[]){
  7         av_register_all();
  8         return 0;
  9 }

私のヘッダーファイルは次の場所にあります

root@ubuntu:/home/juneyoungoh/getDuration# find / -name "avformat.h"
/root/ffmpeg/libavformat/avformat.h
/usr/local/include/libavformat/avformat.h

で実行しgcc getDuration.cますが、以下のようなメッセージが表示されます。

root@ubuntu:/home/juneyoungoh/getDuration# gcc getDuration.c 
/tmp/ccwjonqH.o: In function `main':
getDuration.c:(.text+0x10): undefined reference to `av_register_all'
collect2: ld returned 1 exit status

率直に言って、私には何がこれを引き起こしているのかわかりません。

回答ありがとうございます。

==========================編集#1 ===================== ======

「ls /usr/local/lib」すると、これが表示されます。

root@ubuntu:/home/juneyoungoh/getDuration# ls /usr/local/lib/
libavcodec.a   libavutil.a    libopus.la       libvpx.a   python2.7
libavdevice.a  libfdk-aac.a   libpostproc.a    libx264.a
libavfilter.a  libfdk-aac.la  libswresample.a  libyasm.a
libavformat.a  libopus.a      libswscale.a     pkgconfig

最後の行の一番最初に libavformat.a が表示されます。

したがって、あなたが提案するようにコマンドを実行すると、以下になります。

/root/ffmpeg/libavformat/vqf.c:244: undefined reference to `av_free_packet'
/usr/local/lib//libavformat.a(vqf.o): In function `add_metadata':
/root/ffmpeg/libavformat/vqf.c:58: undefined reference to `av_malloc'
/root/ffmpeg/libavformat/vqf.c:64: undefined reference to `av_dict_set'
/usr/local/lib//libavformat.a(vqf.o): In function `vqf_read_header':
/root/ffmpeg/libavformat/vqf.c:148: undefined reference to `av_dict_set'
/root/ffmpeg/libavformat/vqf.c:208: undefined reference to `av_log'
/root/ffmpeg/libavformat/vqf.c:216: undefined reference to `av_malloc'
/root/ffmpeg/libavformat/vqf.c:170: undefined reference to `av_log'
/root/ffmpeg/libavformat/vqf.c:121: undefined reference to `av_log'
/root/ffmpeg/libavformat/vqf.c:184: undefined reference to `av_log'
/root/ffmpeg/libavformat/vqf.c:136: undefined reference to `av_log'
/usr/local/lib//libavformat.a(wavenc.o): In function `wav_write_trailer':
/root/ffmpeg/libavformat/wavenc.c:210: undefined reference to `av_rescale'
/usr/local/lib//libavformat.a(wavenc.o): In function `wav_write_packet':
/root/ffmpeg/libavformat/wavenc.c:181: undefined reference to `av_log'

長くなりましたので、一部だけ掲載します。

libavformat のリンクがすべて壊れていると思いますが、わかりません

そのリンクを修正するにはどうすればよいですか。

彼らの公式リンクが言ったことをインストールしました。

https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuideQuantal

4

2 に答える 2

0

私は自分のコードに問題があることを発見しました (正確には、コードではなく環境です)。

そのコードを実行するには、「libavformat-dev」という名前の追加のライブラリが必要です。

私の場合、Ubuntu 12.04 ユーザーなので、以下のようにコマンドを実行しました。

apt-get install libavformat-dev

私にはとても恥ずかしいです:(

于 2013-06-17T07:29:44.467 に答える