我试图在运行Ubuntu14.04的机器上编译spdif-环。它在GitHub页面上说,要求是ffmpeg或libav和libao。我在这方面的经验非常有限,但我认为我应该查看make文件以获得更多的细节,并找到了这一行:
LDFLAGS+= -lavcodec -lavformat -lavdevice -lavutil -lao -lm我的猜测是,我可以安装如下所需的依赖项:
sudo apt-get install libavcodec-dev libavformat-dev libavdevice-dev libavutil-dev libao-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libao-dev is already the newest version.
libavcodec-dev is already the newest version.
libavdevice-dev is already the newest version.
libavformat-dev is already the newest version.
libavutil-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.当我试图编译时,我得到以下结果:
livewire@za20:~/Projects/Software/spdif-loop$ make
cc -Wall -std=c99 -g -lavcodec -lavformat -lavdevice -lavutil -lao -lm spdif-loop.c -o spdif-loop
/tmp/ccGCH40C.o: In function `alsa_reader':
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:41: undefined reference to `av_read_frame'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:80: undefined reference to `av_free_packet'
/tmp/ccGCH40C.o: In function `probe_codec':
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:91: undefined reference to `av_init_packet'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:92: undefined reference to `av_read_frame'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:95: undefined reference to `av_free_packet'
/tmp/ccGCH40C.o: In function `open_output':
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:118: undefined reference to `ao_open_live'
/tmp/ccGCH40C.o: In function `test_audio_out':
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:151: undefined reference to `cos'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:160: undefined reference to `ao_play'
/tmp/ccGCH40C.o: In function `main':
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:209: undefined reference to `av_register_all'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:210: undefined reference to `avcodec_register_all'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:211: undefined reference to `avdevice_register_all'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:212: undefined reference to `ao_initialize'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:216: undefined reference to `ao_append_option'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:220: undefined reference to `ao_default_driver_id'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:222: undefined reference to `ao_driver_id'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:232: undefined reference to `av_find_input_format'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:236: undefined reference to `av_find_input_format'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:241: undefined reference to `av_malloc'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:253: undefined reference to `avformat_close_input'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:255: undefined reference to `avformat_close_input'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:257: undefined reference to `ao_close'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:265: undefined reference to `avformat_alloc_context'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:269: undefined reference to `avformat_open_input'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:275: undefined reference to `av_init_packet'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:277: undefined reference to `avio_alloc_context'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:281: undefined reference to `avformat_open_input'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:290: undefined reference to `avcodec_find_decoder'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:296: undefined reference to `avcodec_alloc_context3'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:300: undefined reference to `avcodec_open2'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:304: undefined reference to `av_init_packet'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:311: undefined reference to `av_free_packet'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:312: undefined reference to `av_read_frame'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:320: undefined reference to `avcodec_get_frame_defaults'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:322: undefined reference to `avcodec_decode_audio4'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:339: undefined reference to `av_get_bytes_per_sample'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:346: undefined reference to `av_samples_get_buffer_size'
/home/livewire/Projects/Software/spdif-loop/spdif-loop.c:370: undefined reference to `ao_play'
collect2: error: ld returned 1 exit status
make: *** [spdif-loop] Error 1更多的猜测试图找到或解决这个问题:
livewire@za20:~/Projects/Software/spdif-loop$ grep av_read_frame /usr/include/libavformat/*
/usr/include/libavformat/avformat.h: * avformat_open_input() function for opening a file, av_read_frame() for
/usr/include/libavformat/avformat.h: * av_read_frame() on it. Each call, if successful, will return an AVPacket
/usr/include/libavformat/avformat.h: * until the next av_read_frame() call or closing the file. If the caller
/usr/include/libavformat/avformat.h: /* av_read_frame() support */
/usr/include/libavformat/avformat.h: * appear in av_read_frame().
/usr/include/libavformat/avformat.h: * Use av_read_frame() instead.
/usr/include/libavformat/avformat.h: * av_read_frame() or until av_close_input_file(). Otherwise the packet is valid
/usr/include/libavformat/avformat.h:int av_read_frame(AVFormatContext *s, AVPacket *pkt);所以我想,头文件和文件中的一个函数是存在的?
我试着四处搜索,我发现了一些类似的问题,其中包含了更复杂的Android项目的生成文件,我认为这是错误的方向。我也找到了这是常见问题中的说明。,但我认为这是一个C程序,而不是C++。我只是看看向我提出的类似问题。
就像我说的,我几乎没有经验,你能告诉我我做错了什么吗?我错过了什么,或者需要添加什么才能正确地构建?
我也试过
LDFLAGS+= -lavcodec -lavformat -lavdevice -lavutil -lao -lm -L/usr/include/libavformat和
LDFLAGS+= -lavcodec -lavformat -lavdevice -lavutil -lao -lm -L/usr/lib/x86_64-linux-gnu在make文件中,没有成功,也没有进展。
发布于 2015-04-18 17:11:43
尝试使用以下Makefile:
PROG= spdif-loop
CFLAGS+= -Wall -std=c99 -g
LDFLAGS+= -lavcodec -lavformat -lavdevice -lavutil -lao -lm
all: ${PROG}
$(PROG): $(PROG).c
cc $(CFLAGS) $(PROG).c $(LDFLAGS) -o $(PROG)
clean:
-rm -f ${PROG}在我的Ubuntu14.xx上它编译!
https://stackoverflow.com/questions/29719970
复制相似问题