Clion how Project introduces the FFmpeg library

Source: Internet
Author: User




https://blog.csdn.net/biezhihua/article/details/52734662






Preface






The two days installed on the Mac mounted a ffmpeg, and created a clion C + + project, in the introduction of FFmpeg as a libraries encountered some problems, recorded. How to install FFmpeg






Please look at this document, not much: MAC INSTALL FFMPEG

clion How Project introduces Lib Setup 1






After installing the FFmpeg:




/usr/local/cellar/ffmpeg/3.1.4/include

/usr/local/cellar/ffmpeg/3.1.4/lib


The directory is copied to the project root (in fact, it can not be copied, directly into the CMakeLists.txt directly into the absolute Path can also) Setup 2






Introduction of include and Lib in CMakeLists.txt






There are several ways to use the CMake: Include_directories is used to introduce the. h file link_directories used to tell the project Lib the location target_link_libraries the Lib link into the project






Where Target_link_libraries's position is to be placed after add_executable.






Also note that the first parameter of Target_link_libraries is the project name, which is Project (Ffmpegdemo) in CMakeLists.txt. The Lib name of the target_link_libraries is similar to the position of the lib*.a in LIBAVCODEC.A, that is to say Libavcodec.a's lib name is Avcodec






Example




Include_directories (./include/)

link_directories (./lib/)


set (Source_files main.cpp)


add_executable ( Ffmpegdemo ${source_files})


target_link_libraries (

       ffmpegdemo

       avcodec

       avdevice

       avfilter

       avformat

       avresample

       avutil

       postproc

       swresample

       swscale

)


Write a simple sample code to verify that the success was introduced. Note: Because it is a C + + project, the introduction of header files requires extern "C" {}


extern "C" {#include <libavformat/avformat.h> #include <libavcodec/avcodec.h>}


using namespace Std;

   int main () {cout << "result" << Endl;

   cout << avcodec_configuration ();

return 0; }

Result:


result--prefix=/usr/local/cellar/ffmpeg/3.1.4- -enable-shared--enable-pthreads--ENABLE-GPL--enable-version3--enable-hardcoded-tables--enable-avresample--cc= Clang--host-cflags=--host-ldflags=--enable-opencl--enable-libx264--enable-libmp3lame--enable-libxvid-- Disable-lzma--enable-vda Process finished with exit code 0

 copyright notice: This article for Bo Master original article, without Bo Master permission not reproduced. https://blog.csdn.net/biezhihua/article/details/52734662


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.