<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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><span style="font-size: 11pt;">Thanks, Charles.</span></p>
<p><br>
</p>
<p><span style="font-size: 11pt;">I followed your suggestion by using "</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 13.3333px;"><span style="font-size: 11pt;">--extra-libs=-L/<path
 to>/mylibrary/ -lmylibrarytest -lstdc++" when compiling FFmpeg</span><span style="font-size: 11pt;">, the previous errors disappeared
</span><img class="EmojiInsert" id="OWAEmoji58219" alt="😊" style="vertical-align: bottom;" src="cid:939ee900-299a-4d90-aab9-d49d0155c56d"><span style="font-size: 11pt;">Thanks a lot.</span></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: 13.3333px;"><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: 13.3333px;"><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 11pt;">If
 I only added the above argument</span><span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 13.3333px;"><span style="font-size: 11pt;"> and
 the dependency of FFmpeg on my library, the compiling was successful. But if I put "#include "mylibrary_header.h" " to the FFmpeg filter file, libavfilter/vf_myfilter.c, I got the following error. (Basically, I want to write a FFmpeg filter in C which calls
 my library through the C API file in my library. The core code of my library is in C++ and uses C++ OpenCV, as you described). It is said we can enable the libopencv in FFmpeg, but my case is different. I do not enable the libopencv directly. In my case, the
 opencv is indirectly used by FFmpeg by calling my library. Should I still </span><span style="font-size: 11pt;">play with any opencv setting/flag stuff when compiling FFmepg?</span></span></span></p>
<p><br>
</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: 13.3333px;"></p>
<p class="p1"><span class="s1">libavfilter/libavfilter.so: undefined reference to `cv::fastFree(void*)'</span></p>
<p class="p1"><span class="s1">libavfilter/libavfilter.so: undefined reference to `cv::Mat::deallocate()'</span></p>
<p class="p1"><span class="s1">collect2: error: ld returned 1 exit status</span></p>
<p class="p1"><span class="s1">make: *** [ffprobe_g] Error 1</span></p>
<p class="p1"><span class="s1">make: *** Waiting for unfinished jobs....</span></p>
<p class="p1"><span class="s1">libavfilter/libavfilter.so: undefined reference to `cv::fastFree(void*)'</span></p>
<p class="p1"><span class="s1">libavfilter/libavfilter.so: undefined reference to `cv::Mat::deallocate()'</span></p>
<p class="p1"><span class="s1">collect2: error: ld returned 1 exit status</span></p>
<p class="p1"><span class="s1">make: *** [ffmpeg_g] Error 1</span></p>
<p class="p2"><span class="s1"></span><br>
</p>
<p class="p1"><span class="s1">+status fail (honored)</span></p>
<br>
</span>
<p></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: 13.3333px;"><br>
<span style="font-family: Calibri, Arial, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 13.3333px;"></span></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: 11pt;">Thanks a lot.</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: 13.3333px;"><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: 11pt;">Rich</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: 13.3333px;"><br>
</span></p>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>发件人:</b> Libav-user <libav-user-bounces@ffmpeg.org> 代表 Charles <linux2@orion15.org><br>
<b>发送时间:</b> 2016年9月5日 0:12<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>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On 09/04/2016 01:45 AM, R n wrote:<br>
> Thanks, Charles.<br>
><br>
><br>
> I just want to build it anyway to make it work 😊<br>
><br>
<br>
Been there, just once... ;-)<br>
<br>
After writing this I kinda think this is all you need to do, MAYBE, re-configure ffmpeg and change the order<br>
<br>
--extra-libs=-L/<path to>/mylibrary/ -lmylibrarytest -lstdc++<br>
<br>
See explanation and more info below.<br>
<br>
><br>
> .../binutils/2.25/centos6-native/da39a3e/bin/ld: .../mylibrary/0.1/gcc-4.9-glibc-2.20/80414d5/lib/libmylibrary.a(mylibrary_file.o):<br>
> relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC<br>
><br>
> .../mylibrary/0.1/gcc-4.9-glibc-2.20/80414d5/lib/libmylibrary.a: error adding symbols: Bad value<br>
><br>
> collect2: error: ld returned 1 exit status<br>
><br>
> make: *** [libavfilter/libavfilter.so.6] Error 1<br>
<br>
At this point I realized what you are doing...had to go reread your first message.<br>
<br>
Your build<br>
"The wrapper consists of a C header file and some C functions which call the C++ functions (in the C++ files)"<br>
<br>
I guess you mean something like this mylibrary_file.cpp<br>
<br>
MylibraryClass myobj;<br>
extern "C" void mylib_magic_c_foo()<br>
{<br>
    myobj.DoTheMagicFoo();<br>
}<br>
<br>
Build your lib with fPIC on each object (source file)->(.o)<br>
<br>
g++ -fPIC -O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector [blah blah] ... -o mylibrary_file.o -c mylibrary_file.cpp<br>
<br>
Then build your library as a shared lib<br>
<br>
LDFLAGS += -fPIC -shared<br>
<br>
g++ -fPIC -shared -O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector [blah blah]... mylibrary_file.o -o libmylibrary.so<br>
<br>
When ffmpeg builds it need to do the -L.../<path to>/mylibrary/ -lmylibrary -lstdc++<br>
<br>
The -L path then your mylibrary all before -lstdc++ (linker "express need then satisfy need")<br>
<br>
--extra-libs=-L/<path to>/mylibrary/ -lmylibrarytest -lstdc++'<br>
<br>
No idea if it will work, just a theory...sorry not an expert<br>
<br>
><br>
> The full building commands are too big and I just copied something (below) I feel important. Please let me know if I missed anything.<br>
> 2. This is the compile command for building FFmpeg (which is calling my library):<br>
><br>
> CFLAGS='-O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fno-omit-frame-pointer<br>
> -momit-leaf-frame-pointer -m64 -mtune=generic -nostdinc -grecord-gcc-switches ... -fPIC'<br>
[...]<br>
> Here, I did not see anything like "Wextra -DDEBUG..."<br>
<br>
FYI : They don't have anything to do with your problem<br>
-W is options passed to compiler -Wl is passed to linker and -D is defines passed to C Pre Processor<br>
-Wextra is added to -Wall for compile warnings, I used it for -Wmissing-field-initializers and -Wunused-parameter<br>
-DDEBUG is just enabling my code where I have #if defined(DEBUG)<br>
<br>
<br>
> 3. This is the compile command for building my library:<br>
> CFLAGS='-O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fno-omit-frame-pointer<br>
> -momit-leaf-frame-pointer -m64 -mtune=generic -nostdinc -grecord-gcc-switches ...<br>
[...]<br>
>>                    '--extra-libs=-L /lib64 -lstdc++ -lmylibrarytest',<br>
>><br>
>> .../binutils/2.25/centos6-native/da39a3e/bin/ld: .../mylibrary/0.1/gcc-4.9-glibc-2.20-fb/8fd4fe1/lib/libmylibrary.a(my_file.cpp.o):<br>
>> relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC<br>
><br>
> -fPIC is for shared objects, you have to compile all the object code with -fPIC to build a shared library.<br>
> libmylibrary.a is a static lib so you probably should not be using -fPIC<br>
> The -lstdc++ indicates you are at least linking against it.<br>
> Are you doing a cross compile? Centos 6 should be gcc 4.4.7ish and I thought 4.9 was Centos 7<br>
><br>
>> .../mylibrary/0.1/gcc-4.9-glibc-2.20/8fd4fe1/lib/libmylibrary.a: error adding symbols: Bad value<br>
<br>
Hope this helps...<br>
<br>
Thanks<br>
cco<br>
_______________________________________________<br>
Libav-user mailing list<br>
Libav-user@ffmpeg.org<br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" id="LPlnk400263">http://ffmpeg.org/mailman/listinfo/libav-user</a>
<div id="LPBorder_GT_14730476366980.14654633875471101" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_14730476366950.34307493167054304" cellspacing="0" style="width: 90%; position: relative; overflow: auto; padding-top: 20px; padding-bottom: 20px; margin-top: 20px; border-top-width: 1px; border-top-style: dotted; border-top-color: rgb(200, 200, 200); border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: rgb(200, 200, 200); background-color: rgb(255, 255, 255);">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td id="TextCell_14730476366960.2328010381050858" colspan="2" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;">
<div id="LPRemovePreviewContainer_14730476366960.1442611515860288"></div>
<div id="LPTitle_14730476366960.65934458227821" style="top: 0px; color: rgb(0, 120, 215); font-weight: normal; font-size: 21px; font-family: "Microsoft YaHei UI", "Microsoft YaHei", 微软雅黑, SimSun, 宋体, sans-serif; line-height: 21px;">
<a id="LPUrlAnchor_14730476366970.47418061661502797" href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank" style="text-decoration: none;">Libav-user Info Page - FFmpeg</a></div>
<div id="LPMetadata_14730476366970.4995666388818012" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: normal; font-family: "Microsoft YaHei UI", "Microsoft YaHei", 微软雅黑, SimSun, 宋体, sans-serif; font-size: 14px; line-height: 14px;">
ffmpeg.org</div>
<div id="LPDescription_14730476366970.45789534505595264" style="display: block; color: rgb(102, 102, 102); font-weight: normal; font-family: "Microsoft YaHei UI", "Microsoft YaHei", 微软雅黑, SimSun, 宋体, sans-serif; font-size: 14px; line-height: 20px; max-height: 100px; overflow: hidden;">
This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter. To see the collection of prior postings to the list, visit the Libav-user ...</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>