[英]How to link ffmpeg library by cmake?
I want to use ffmpeg library in my c++ program. 我想在我的C ++程序中使用ffmpeg库。
I've downloaded ffmpeg source. 我已经下载了ffmpeg源码。
During make&compile process, i had this error: 在生成和编译过程中,我遇到此错误:
UINT64_C not defined! UINT64_C未定义!
After some search: 经过一番搜索:
1.Adding the following code to libavutil/common.h 1.将以下代码添加到libavutil / common.h
#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif
2. ./configure&compile
had solved that problem. 2.
./configure&compile
解决了该问题。
But now i want to link this library to a simple encoding method by using cmake files. 但是现在我想通过使用cmake文件将此库链接到一种简单的编码方法。
I've tried some sample of CMakeLists.txt but i still have 我已经尝试了CMakeLists.txt的一些示例,但我仍然有
"undefined refrence " error “未定义的参考”错误
many thanks! 非常感谢!
you ought to write a finder for ffmpeg
library, then use it in your cmake-enabled project to detect a correct location and all required files (headers and libs), possible allowing to user to override search results (if we are talking about a really good finder)... 您应该为
ffmpeg
库编写一个查找程序,然后在启用了cmake的项目中使用它来检测正确的位置和所有必需的文件(标头和库),可能允许用户覆盖搜索结果(如果我们正在谈论一个真正的好发现者)...
there are plenty tutorials about how to do that over the net. 有很多关于如何通过网络执行此操作的教程。 moreover, it will be relatively easy, because
ffmpeg
has a bunch of .pc
files (at least in my gentoo system), so all that you need is to reuse pkg-config
to "detect" it... and cmake have a module called FindPkgConfig
w/ macro pkg_check_modules
to even more simplify this task. 而且,这将相对容易些,因为
ffmpeg
有一堆.pc
文件(至少在我的gentoo系统中),因此您所需要的只是重用pkg-config
来“检测”它...并且cmake拥有一个模块带有宏pkg_check_modules
名为FindPkgConfig
pkg_check_modules
程序甚至可以进一步简化此任务。 after all, do not forget to use FindPackageHandleStandardArgs
. 毕竟,不要忘记使用
FindPackageHandleStandardArgs
。
read details in a /usr/share/cmake/Modules/readme.txt
or google it... 在
/usr/share/cmake/Modules/readme.txt
阅读详细信息,或在Google上搜索...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.