<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>By the way, I have also been playing with the compiling flags for FFmpeg, but got different errors. For example: </p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;"><br>
</span></p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">I </span><span style="font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">used </span><span style="font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">'--extra-libs=-lmylibrary -L/usr/lib64
 -lstdc++', and got:</span></p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 12pt;"></span></p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 12pt;"><br>
</span></p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;"></span></p>
<p class="p1"><span class="s1">.../binutils/2.25/centos6-native/da39a3e/bin/ld: .../<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; widows: auto;">mylibrary</span>/0.1/gcc-4.9-glibc-2.20-fb/80414d5/lib/libmylibrary.a(<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; widows: auto;">mylibrary_file</span>.cpp.o):
 relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC</span></p>
<p class="p1"><span class="s1"><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">.../mylibrary</span>/0.1/gcc-4.9-glibc-2.20-fb/80414d5/lib/lib<span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">mylibrary</span>.a:
 error adding symbols: Bad value</span></p>
<p class="p1"><span class="s1"><br>
</span></p>
<p class="p1"><span class="s1"><br>
</span></p>
<p class="p1">Thanks.</p>
<p class="p1"><br>
</p>
<p class="p1">Rich</p>
<p></p>
<p></p>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>发件人:</b> Libav-user <libav-user-bounces@ffmpeg.org> 代表 R n <flynewdream@hotmail.com><br>
<b>发送时间:</b> 2016年9月3日 3:54<br>
<b>收件人:</b> This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.<br>
<b>主题:</b> [Libav-user] 答复: Are there any ways to use a lib (built from C++ OpenCV) in Ffmpeg filter?</font>
<div> </div>
</div>
<div>
<div id="divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Thanks <span style="font-family:Calibri,Arial,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px">Perette.</span></p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px"><br>
</span></p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px">I did exactly what you suggested for the C and C++ files. (I have two header files,
 one for C and another is for C++, and the C++ <span style="font-family:Calibri,Arial,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px">
header file</span> includes the C header file. I have one cpp file in which I put the C and C++ source code. I can also split them into two cpp files for clarity). I guess perhaps the problem is in the how I compile the library and how I compile FFmpeg when
 I call the library from FFmpeg.</span></p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px"><br>
</span></p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px">Any suggestions?</span></p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px"><br>
</span></p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px">Thanks.</span></p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px"><br>
</span></p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px">Rich </span></p>
<p><br>
</p>
<div id="Signature">
<p><br>
</p>
</div>
<br>
<br>
<div style="color:rgb(0,0,0)">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>发件人:</b> Libav-user <libav-user-bounces@ffmpeg.org> 代表 Perette Barella <perette@barella.org><br>
<b>发送时间:</b> 2016年9月3日 3:38<br>
<b>收件人:</b> This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.<br>
<b>主题:</b> Re: [Libav-user] Are there any ways to use a lib (built from C++ OpenCV) in Ffmpeg filter?</font>
<div> </div>
</div>
<div>
<div>
<blockquote type="cite" class="">
<div class="">On 2016年09月02日, at 22:32, R n <<a href="mailto:flynewdream@hotmail.com" class="">flynewdream@hotmail.com</a>> wrote:</div>
<div class="">
<div id="divtagdefaultwrapper" class="" style="font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; font-size:12pt; background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif">
<div class="" style="margin-top:0px; margin-bottom:0px"><span class="s1">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.</span></div>
</div>
</div>
</blockquote>
<span class="" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; background-color:rgb(255,255,255)">…</span><br class="">
<blockquote type="cite" class="">
<div class="">
<div id="divtagdefaultwrapper" class="" style="font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; font-size:12pt; background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif">
<div class="" style="margin-top:0px; margin-bottom:0px"><span class="s1"></span></div>
<div class="" style="margin-top:0px; margin-bottom:0px"><span class="s1">However, I get the following error when compiling FFmpeg:</span></div>
<div class="" style="margin-top:0px; margin-bottom:0px"><span class="s1">.../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'</span></div>
<div class="" style="margin-top:0px; margin-bottom:0px"><span class="s1">.../libgcc/4.9.x/gcc-4.9-glibc-2.20/024dbc3/lib/libstdc++.so: error adding symbols: DSO missing from command line</span></div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>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”:</div>
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="" style="margin:0px; line-height:normal; font-family:Courier"><span class="" style="">#ifdef __cplusplus</span></div>
<div class="" style="margin:0px; line-height:normal; font-family:Courier"><span class="" style="">#warning is c++</span></div>
<div class="" style="margin:0px; line-height:normal; font-family:Courier"><span class="" style="">extern "C" {</span></div>
<div class="" style="margin:0px; line-height:normal; font-family:Courier"><span class="" style="">#endif</span></div>
<div class="" style="margin:0px; line-height:normal; font-family:Courier"><span class="" style=""><span class="Apple-tab-span" style="white-space:pre"></span>char foo (int);</span></div>
<div class="" style="margin:0px; line-height:normal; font-family:Courier; min-height:14px">
<span class="" style=""></span><br class="">
</div>
<div class="" style="margin:0px; line-height:normal; font-family:Courier"><span class="" style="">#ifdef __cplusplus</span></div>
<div class="" style="margin:0px; line-height:normal; font-family:Courier"><span class="" style="">}</span></div>
<div class="" style="margin:0px; line-height:normal; font-family:Courier"><span class="" style="">#endif</span></div>
</div>
<div class=""><span class="" style=""><br class="">
</span></div>
<div class="">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.</div>
<div class=""><br class="">
</div>
<div class="">Perette</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>