thanks Jeff, I wrapped the #include with <br><br>#ifdef __cplusplus<br>extern "C"{<br>#endif<br><br>...<br><br>#ifdef __cplusplus<br>}<br>#endif<br><br>and the inline problem is gone, it's no long needed, the app works like a charm!<br>
<br>Thought: I did wrap with "extern C{}" before, but I didn't put the conditional macro (#ifdef __cplusplus) then as I did it now, guess I used it the wrong way then.<br><br>Thanks again, Hai<br><br><br><div class="gmail_quote">
On Wed, Jun 9, 2010 at 2:31 AM, Jeff Newmiller <span dir="ltr"><<a href="mailto:jdnewmil@dcn.davis.ca.us">jdnewmil@dcn.davis.ca.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Hai Yi wrote:<br>
> Thanks Jeff. However, the header file of those C routines are included<br>
> in ffmpegmgr.h, which is in turn included by ffmpegmgr.cpp.<br>
><br>
> The "undefined reference " normally indicates that the functions's<br>
> definitions are not found, and it takes place when doing the linker.<br>
<br>
</div>I am aware of that. However, if you don't have your calls properly declared<br>
then the linking may fail.<br>
<div class="im"><br>
> The<br>
> libraries, libavcodec, etc, have been specified from the g++ command<br>
> line, and seems to work - only that I need to make the encapulated<br>
> member function in ffmpegmgr.cpp inline to eliminate the linker error:<br>
><br>
> inline void FFMpegMgr::new_video_stream(AVFormatContext *oc)<br>
> {<br>
> ...<br>
> st = av_new_stream(oc, oc->nb_streams);<br>
> ...<br>
> }<br>
<br>
</div>I cannot explain that. Adding the inline keyword to new_video_stream<br>
eliminates new_video_stream from the linking process (being placed inline,<br>
there is no need to link it), but should have no effect on the link-ability<br>
of av_new_stream.<br>
<br>
Are you wrapping your C declarations as seen from C++ in extern "C" {}<br>
blocks? This is often done by wrapping the #include statement for the C<br>
header file in your cpp or C++ header files.<br>
<div class="im"><br>
> Also, the lib that I specified is *.a, will it be different if the lib<br>
> is *.so ?<br>
<br>
</div>If you declare your objects correctly, there should be no need for source<br>
code changes between static and shared library linking.<br>
<div class="im"><br>
> Thanks,<br>
> Hai<br>
><br>
><br>
> On Mon, Jun 7, 2010 at 1:26 AM, Jeff Newmiller <<a href="mailto:jdnewmil@dcn.davis.ca.us">jdnewmil@dcn.davis.ca.us</a><br>
</div><div class="im">> <mailto:<a href="mailto:jdnewmil@dcn.davis.ca.us">jdnewmil@dcn.davis.ca.us</a>>> wrote:<br>
><br>
> Seems more likely that you haven't included the declarations for the<br>
> C routines in your cpp file. Would need to see more context to diagnose.<br>
><br>
</div><div class="im">> "Hai Yi" <<a href="mailto:yihai2004@gmail.com">yihai2004@gmail.com</a> <mailto:<a href="mailto:yihai2004@gmail.com">yihai2004@gmail.com</a>>> wrote:<br>
><br>
> >Hello all:<br>
> ><br>
> >I created a class FFMpegMgr and a method init(); inside init() I<br>
> just put<br>
> >three ffmpeg api there:<br>
> >avcodec_register_all();<br>
> >avdevice_register_all();<br>
> > av_register_all();<br>
> ><br>
> >The source file ffmpegmgr.cpp look like this:<br>
> ><br>
> > void FFMpegMgr::init() {<br>
> > avcodec_register_all();<br>
> > avdevice_register_all();<br>
> > av_register_all();<br>
> ><br>
> >}<br>
> ><br>
> >Now I got a "undefined reference to avcodec_register_all" error.<br>
> ><br>
> >if I put that body in the class declaration or add a "inline"<br>
> keyword, that<br>
> >problem was gone and the compilation succeeded.<br>
> ><br>
> >question is, do those three functions, which are C functions<br>
> defined in<br>
> >avcodec.h, have to be used only in the inline functions in C++?<br>
> ><br>
> >Sorry if it appear naive - I've been out of touch with C/C++ for a<br>
> while.<br>
> ><br>
> >Thanks!<br>
> >Hai<br>
<br>
<br>
</div>--<br>
<div><div></div><div class="h5">---------------------------------------------------------------------------<br>
Jeff Newmiller The ..... ..... Go Live...<br>
DCN:<<a href="mailto:jdnewmil@dcn.davis.ca.us">jdnewmil@dcn.davis.ca.us</a>> Basics: ##.#. ##.#. Live Go...<br>
Live: OO#.. Dead: OO#.. Playing<br>
Research Engineer (Solar/Batteries O.O#. #.O#. with<br>
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k<br>
---------------------------------------------------------------------------<br>
_______________________________________________<br>
vox-tech mailing list<br>
<a href="mailto:vox-tech@lists.lugod.org">vox-tech@lists.lugod.org</a><br>
<a href="http://lists.lugod.org/mailman/listinfo/vox-tech" target="_blank">http://lists.lugod.org/mailman/listinfo/vox-tech</a><br>
</div></div></blockquote></div><br>