本文介绍了C程序找不到包含在头文件中的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我的头文件位于

  root @ ubuntu:/ home / juneyoungoh / getDuration#find / -nameavformat.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:在函数`main'中:
getDuration.c :( .text + 0x10):未定义的引用`av_register_all'
collect2:ld返回1退出状态

坦白说,我不知道这是什么感谢您的回答。



============ ============编辑#1 =========================



当我ls / usr / local / lib时,我得到这个。

  root @ ubuntu :/ home / juneyoungoh / getDuration#ls / usr / local / lib / 
libavcodec.a liba vutil.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:未定义的引用av_free_packet
/usr/local/lib//libavformat.a(vqf.o):在函数中`add_metadata':
/root/ffmpeg/libavformat/vqf.c:58:对'av_malloc'的定义引用
/root/ffmpeg/libavformat/vqf.c:64:未定义的引用`av_dict_set'
/usr/local/lib//libavformat.a(vqf.o):在函数`vqf_read_header'中:
/root/ffmpeg/libavformat/vqf.c:148:未定义的引用`av_dict_set'
/root/ffmpeg/libavformat/vqf.c:208:未定义的引用av_log
/ root / ffmpeg / libavformat / vqf。 c:216:未定义的引用av_malloc
/root/ffmpeg/libavformat/vqf.c:170:对'av_log'的定义引用
/root/ffmpeg/libavformat/vqf.c:121:未定义的引用av_log
/root/ffmpeg/libavformat/vqf.c:184:未定义的引用av_log
/root/ffmpeg/libavformat/vqf.c:136:未定义引用 av_log'
/usr/local/lib//libavformat.a(wavenc.o):在函数`wav_write_trailer'中:
/root/ffmpeg/libavformat/wavenc.c:210:undefined reference to` av_rescale'
/usr/local/lib//libavformat.a(wavenc.o):在函数`wav_write_packet'中:
/root/ffmpeg/libavformat/wavenc.c:181:未定义引用` av_log'

太长了,所以我刚刚发布了一小部分。



我认为libavformat的所有链接已被打破,但是我不知道



我可以如何修复该链接。 / p>

我已经安装了他们的官方链接说。



解决方案

我发现我的代码有错(完全不是代码,而是环境)。



要执行该代码,我需要额外的库命名为libavformat-dev。



在我的情况下,由于我是Ubuntu 12.04用户,我命令如下。

  apt-get install libavformat-dev 

羞耻我:(


I made program like this.

  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 }

My header file located in

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

then I run with gcc getDuration.c , but I show message like below.

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

Frankly, I do not have any idea what makes this.

Thanks for your answers.

========================== edited #1 ===========================

when I "ls /usr/local/lib", I get this.

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

you can see libavformat.a in the very first of the last line.

so if I command like what you suggest, I get below.

/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'

It is too long, so I just post little part of that.

I think all link of libavformat has been broken, But I do not know

what can I do to fix that link.

I have installed that their official link said.

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

解决方案

I found what wrong with my code(exactly, not code, but environment).

To execute that code, I need extra library which named "libavformat-dev".

In my case, since I am Ubuntu 12.04 user, I commanded like below.

apt-get install libavformat-dev

such a shame on me :(

这篇关于C程序找不到包含在头文件中的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-07 06:06