[英]Linker links correct file, but fails to find symbols
I'm playing around with libav*. 我正在玩libav *。 I wrote a simple program to open a file and output how many streams it has in it, just something to get my feet wet.
我写了一个简单的程序来打开一个文件并输出它中有多少个流,这些东西让我的脚湿透了。 I link with avformat, avcodec and avutil.
我链接avformat,avcodec和avutil。 However, I get undefined reference errors from ld.
但是,我从ld得到未定义的引用错误。 The undefined references are all libav* functions.
未定义的引用都是libav *函数。 I took a look at the verbose linker output and see that it is linking with the correct libraries and I used objdump to confirm that the symbols are located in the library, but ld still throws undefined reference errors.
我查看了详细的链接器输出,看到它是否与正确的库链接,我使用objdump确认符号位于库中,但ld仍然会抛出未定义的引用错误。
Are you programming in C++? 你在用C ++编程吗? If that's the case, you need to add 'extern "C" {...};'.
如果是这种情况,则需要添加“extern”C“{...};”。
Take a look here: Why do we need extern "C"{ #include <foo.h> } in C++? 看看这里: 为什么我们需要在C ++中使用extern“C”{#include <foo.h>}? and note that libav* is written in C.
并注意libav *是用C语言编写的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.