<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><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" style="font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px; font-size: 12pt; background-color: rgb(255, 255, 255); font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><div style="margin-top: 0px; margin-bottom: 0px;" class=""><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 style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);" class="">…</span><br class=""><blockquote type="cite" class=""><div class=""><div id="divtagdefaultwrapper" style="font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px; font-size: 12pt; background-color: rgb(255, 255, 255); font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span class="s1"></span></div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span class="s1">However, I get the following error when compiling FFmpeg:</span></div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><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 style="margin-top: 0px; margin-bottom: 0px;" class=""><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 style="margin: 0px; line-height: normal; font-family: Courier;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">#ifdef __cplusplus</span></div><div style="margin: 0px; line-height: normal; font-family: Courier;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">#warning is c++</span></div><div style="margin: 0px; line-height: normal; font-family: Courier;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">extern "C" {</span></div><div style="margin: 0px; line-height: normal; font-family: Courier;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">#endif</span></div><div style="margin: 0px; line-height: normal; font-family: Courier;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>char foo (int);</span></div><div style="margin: 0px; line-height: normal; font-family: Courier; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Courier;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">#ifdef __cplusplus</span></div><div style="margin: 0px; line-height: normal; font-family: Courier;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; line-height: normal; font-family: Courier;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">#endif</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><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></body></html>