"undefined reference" 尝试编译 spdif-loop 时的错误消息
"undefined reference" error messages when trying to compile spdif-loop
我正在尝试在我的机器上编译 spdif-loop 运行 Ubuntu 14.04。它在 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 项目的更复杂的 make 文件,我认为这是错误的方向。我也找到了 this note in the FAQ,但我认为这是一个 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 文件中,没有成功或进展。
尝试使用以下 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}
在我的 Ubuntu 14.xx 上编译!
我正在尝试在我的机器上编译 spdif-loop 运行 Ubuntu 14.04。它在 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 项目的更复杂的 make 文件,我认为这是错误的方向。我也找到了 this note in the FAQ,但我认为这是一个 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 文件中,没有成功或进展。
尝试使用以下 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}
在我的 Ubuntu 14.xx 上编译!