Author Topic: Linking ffmpeg  (Read 22223 times)

Offline computerguy89

  • Single posting newcomer
  • *
  • Posts: 6
Linking ffmpeg
« on: August 25, 2007, 01:57:39 am »
Hi.

First of all I'm using Fedora 7 x86_64, Code::Blocks svn build 4407, wx2.8.4(Linux, unicode).

Okay I'm tying to get ffmpeg to link in my small little Video Player.
I've included avformat.a and avcodec.a. and avutil.a in the linker settings.

But it still fails to compile saying:
Code
ffmpeg/include/ffmpeg/avcodec.h:2243: warning: ‘ImgReSampleContext’ is deprecated (declared at ffmpeg/include/ffmpeg/avcodec.h:2237)
ffmpeg/include/ffmpeg/avcodec.h:2253: warning: ‘ImgReSampleContext’ is deprecated (declared at ffmpeg/include/ffmpeg/avcodec.h:2237)
obj/Debug/VideoStream.o:: In function `VideoStream':
Video/VideoStream.cpp:8: undefined reference to `av_register_all()'
Video/VideoStream.cpp:8: undefined reference to `av_register_all()'
Video/VideoStream.cpp:12: undefined reference to `av_open_input_file(AVFormatContext**, char const*, AVInputFormat*, int, AVFormatParameters*)'
Video/VideoStream.cpp:12: undefined reference to `av_open_input_file(AVFormatContext**, char const*, AVInputFormat*, int, AVFormatParameters*)'
Theres a lot more errors.

Is there configure settings I have to include to get it to compile?


I compiled ffmpeg from svn because the one that come with the RPM failed to compile saying "error: ‘INT64_C’ was not declared in this scope".
So it could have got messed up there.

Any help would be vary much appreciated.
« Last Edit: August 25, 2007, 05:36:55 am by computerguy89 »

Offline wwolf

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: Linking ffmpeg
« Reply #1 on: August 25, 2007, 02:45:41 am »
Do you have the actual command line that printed the linker errors?  Then we could see if the problem is Code::Blocks related or not.

Offline computerguy89

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking ffmpeg
« Reply #2 on: August 25, 2007, 02:55:00 am »
Sorry, But how do you get that?

I'm still a little new to Code::Blocks.


Offline computerguy89

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking ffmpeg
« Reply #3 on: August 25, 2007, 05:23:37 am »
Never mind I figured it out.

Here it is:
Code
g++ -L/usr/lib  -o bin/Debug/VideoPlayer obj/Debug/Main.o obj/Debug/VideoStream.o    ffmpeg/lib/libavcodec.a ffmpeg/lib/libavformat.a ffmpeg/lib/libavutil.a


I have ffmpeg installed in my projects directory.

Is this what you wanted?
« Last Edit: August 25, 2007, 05:25:52 am by computerguy89 »

Offline wwolf

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: Linking ffmpeg
« Reply #4 on: August 25, 2007, 08:18:35 am »
Yes!  Thanks.  Now I am not familiar with ffmpeg on Linux, but I think that you may need to put the whole path into the -L option.  I say may, because I am not sure.  And my Linux box has just disappeared from the Net, so I cannot test it either. :(

What you may want to try is to go to command line (shell) and cd to the directory where Code::Blocks does the build, and try different alternatives of the above linker command line.  Like adding the full path into the -L and removing it from the -l.  In that way you can figure out what works, without the need to open and close dialog boxes.  Once you figure out how you can link without errors, you can put the final stuff back into the relevant Code::Blocks settings and it should work there, too.

I know this is not exactly much help, but right now this is all I can offer. :(

Offline computerguy89

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking ffmpeg
« Reply #5 on: August 26, 2007, 03:18:51 am »
Okay I tried  the -L with the full path and it still didn't compile so I gave up tying with Fedora 7.
And tried it on Fedora core 6 i386 to see if it was related to 64bit and it still didn't compile saying "undefined reference to `av_register_all'".
So I went and found my old hard drive and install Mandriva One 2007 32bit and it worked fine.

Do you think it could be related to Fedora?

Thanks for all your help I really appreciate it.

Offline wwolf

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: Linking ffmpeg
« Reply #6 on: August 26, 2007, 06:00:23 am »
I am not sure if it is related to Fedora itself.  It is certainly related to your Fedora installation.  I was just thinking, is it possible that not all stuff ffmpeg is depending on is installed on your Fedora?  You may also try a Google search with your error message.  Normally problems like this are effecting more than one person, and the solution might be out there already.

Offline computerguy89

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking ffmpeg
« Reply #7 on: August 27, 2007, 01:40:24 am »
Okay I did some Googling and found this, could it be why I can't get ffmpeg to link in C++?

After I read that I tried compiling it with gcc on Fedora and it worked fine. :?

I also found this library called FOBS which is a C++ wrapper for ffmpeg, so hopefully it will work.:)
 
Well, I guess it's related to ffmpeg not supporting C++, not Code::Blocks.
Thanks again for your help.

Offline wwolf

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: Linking ffmpeg
« Reply #8 on: August 27, 2007, 02:37:09 am »
Yeah, I think i understand the issue now.  Perhaps one solution is to wrap the ffmpeg headers into extern "C" blocks when you include them into C++ programs:

extern "C" {
#include <some_ffmpeg_header.h>
}


Offline computerguy89

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking ffmpeg
« Reply #9 on: August 27, 2007, 04:09:16 am »
Yup it works fine now, I guess I just needed the extern "C" thing.

Thanks!