[Libav-user] Are there any ways to use a lib (built from C++ OpenCV) in Ffmpeg filter?

Perette Barella perette at barella.org
Sat Sep 3 06:38:02 EEST 2016

> On 2016年09月02日, at 22:32, R n <flynewdream at hotmail.com> wrote:
> I am writing a C++ library which is based on OpenCV. I want to use it in a Ffmpeg filter (written in C), so I write a wrapper of the library using C. The wrapper consists of a C header file and some C functions which call the C++ functions (in the C++ files). I expect the FFmpeg filter to only include the C header and call the C functions.
> However, I get the following error when compiling FFmpeg:
> .../binutils/2.25/centos6-native/da39a3e/bin/ld: .../mylibrary/0.1/gcc-4.9-glibc-2.20/80414d5/lib/libmylibrary.a(mylibrary_file.cpp.o): undefined reference to symbol '_ZdlPv@@GLIBCXX_3.4'
> .../libgcc/4.9.x/gcc-4.9-glibc-2.20/024dbc3/lib/libstdc++.so: error adding symbols: DSO missing from command line

Your approach is correct, but C++ “mangles” function names to make them unique when considering parameters and such.  You need to specify C linkage, so in your .h file, wrap it in extern “C”:

#ifdef __cplusplus
#warning is c++
extern "C" {
	char foo (int);

#ifdef __cplusplus

You need to #include the .h file in the corresponding .cpp file, so the C++ compiler knows not to mangle those particular function names when they’re compiled.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160902/b60017d3/attachment.html>

More information about the Libav-user mailing list