[Libav-user] Compile with g++

Vitsas Nikolaos p3070011 at dias.aueb.gr
Wed Oct 9 16:59:18 CEST 2013


On Wed, 9 Oct 2013 07:29:52 -0700 (PDT)
  James Board <jpboard2 at yahoo.com> wrote:
> 
>>This is a mailing list about FFmpeg (that is why 
>>it is hosted on the FFmpeg server). Questions 
>>about how to convert a C program (that allows 
>>implicit type conversions which is why FFmpeg 
>>- and demuxing.c - does not contain explicit 
>>type conversions) into a C++ program (which 
>>needs explicit conversions) is not completely 
>>appropriate here afaict.
> 
> Really?  The title of the mailing list is Libav-user at ffmpeg.org.
> I'm asking whether libav can be used in C++ programs, if anyone
> uses libav in C++ programs, and what I need to do in order to
> use libav in C++ programs.  How can that be inappropriate?
> 
> Anyway, don't bother.  I give up.  You win.

You just need to wrap all you libav includes in extern "C" { }, like 
this

  #ifdef __cplusplus

  extern "C" {
  #include <libavutil/avutil.h>
  #include <libavutil/mathematics.h>
  #include <libavutil/imgutils.h>
  #include <libavutil/samplefmt.h>
  #include <libavutil/time.h>
  #include <libavcodec/avcodec.h>
  #include <libavformat/avformat.h>
  #include <libswscale/swscale.h>
  }

  #endif // __cplusplus

  As for UINT64_C you can do this

  #ifndef INT64_C
  #define INT64_C(c) (c ## LL)
  #define UINT64_C(c) (c ## ULL)
  #endif // INT64_C

I' m using libav in many of my projects which include other third 
party libraries. The above are the only things required.


More information about the Libav-user mailing list