<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 3, 2016 at 10:56 AM, R n <span dir="ltr"><<a href="mailto:flynewdream@hotmail.com" target="_blank">flynewdream@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div 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=-<wbr>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><span>.../binutils/2.25/centos6-<wbr>native/da39a3e/bin/ld: .../<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">mylibrary</span>/0.1/gcc-4.9-<wbr>glibc-2.20-fb/80414d5/lib/<wbr>libmylibrary.a(<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">mylibrary_file</span>.<wbr>cpp.o):
 relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC</span></p>
<p><span><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">.../mylibrary</span>/0.1/gcc-4.9-<wbr>glibc-2.20-fb/80414d5/lib/lib<span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">m<wbr>ylibrary</span>.a:
 error adding symbols: Bad value</span></p>
<p><span></span><br></p></div></div></blockquote><div><br> </div><div>I know this error. Try -fPIC -DPIC in the compiler and linker flags.<br><br></div><div><br><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif"><p><span>
</span></p>
<p>Thanks.</p>
<p><br>
</p>
<p>Rich</p>
<p></p>
<p></p>
<br>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block;width:98%">
<div dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>发件人:</b> Libav-user <<a href="mailto:libav-user-bounces@ffmpeg.org" target="_blank">libav-user-bounces@ffmpeg.org</a><wbr>> 代表 R n <<a href="mailto:flynewdream@hotmail.com" target="_blank">flynewdream@hotmail.com</a>><br>
<b>发送时间:</b> 2016年9月3日 3:54<span class=""><br>
<b>收件人:</b> This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.<br>
</span><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 class="h5">
<div>
<div 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>
<p><br>
</p>
</div>
<br>
<br>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block;width:98%">
<div dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>发件人:</b> Libav-user <<a href="mailto:libav-user-bounces@ffmpeg.org" target="_blank">libav-user-bounces@ffmpeg.org</a><wbr>> 代表 Perette Barella <<a href="mailto:perette@barella.org" target="_blank">perette@barella.org</a>><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">
<div>On 2016年09月02日, at 22:32, R n <<a href="mailto:flynewdream@hotmail.com" target="_blank">flynewdream@hotmail.com</a>> wrote:</div>
<div>
<div style="font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:12pt;background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
<div style="margin-top:0px;margin-bottom:0px"><span>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 style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;background-color:rgb(255,255,255)">…</span><br>
<blockquote type="cite">
<div>
<div style="font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:12pt;background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
<div style="margin-top:0px;margin-bottom:0px"><span></span></div>
<div style="margin-top:0px;margin-bottom:0px"><span>However, I get the following error when compiling FFmpeg:</span></div>
<div style="margin-top:0px;margin-bottom:0px"><span>.../binutils/2.25/centos6-<wbr>native/da39a3e/bin/ld: .../mylibrary/0.1/gcc-4.9-<wbr>glibc-2.20/80414d5/lib/<wbr>libmylibrary.a(mylibrary_file.<wbr>cpp.o): undefined reference to symbol '_ZdlPv@@GLIBCXX_3.4'</span></div>
<div style="margin-top:0px;margin-bottom:0px"><span>.../libgcc/4.9.x/gcc-4.9-<wbr>glibc-2.20/024dbc3/lib/<wbr>libstdc++.so: error adding symbols: DSO missing from command line</span></div>
</div>
</div>
</blockquote>
<div><br>
</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><br>
</div>
<div>
<div style="margin:0px;line-height:normal;font-family:Courier"><span>#ifdef __cplusplus</span></div>
<div style="margin:0px;line-height:normal;font-family:Courier"><span>#warning is c++</span></div>
<div style="margin:0px;line-height:normal;font-family:Courier"><span>extern "C" {</span></div>
<div style="margin:0px;line-height:normal;font-family:Courier"><span>#endif</span></div>
<div style="margin:0px;line-height:normal;font-family:Courier"><span><span style="white-space:pre-wrap"></span>char foo (int);</span></div>
<div style="margin:0px;line-height:normal;font-family:Courier;min-height:14px">
<span></span><br>
</div>
<div style="margin:0px;line-height:normal;font-family:Courier"><span>#ifdef __cplusplus</span></div>
<div style="margin:0px;line-height:normal;font-family:Courier"><span>}</span></div>
<div style="margin:0px;line-height:normal;font-family:Courier"><span>#endif</span></div>
</div>
<div><span><br>
</span></div>
<div>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><br>
</div>
<div>Perette</div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div></div></div>
</div>
</div>

<br>______________________________<wbr>_________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/<wbr>listinfo/libav-user</a><br>
<br></blockquote></div><br></div></div>