Ok, so I'm trying to include ffmpeg for decoding of mpeg4 files so I can play with the frame buffer (if you know of a lighter weight way of doing this feel free to let me know). I took the time to compile with minsys and I'd like to include my shiny new files and get on with the encoding or decoding of movies (I even shot a short clip to practice with).
So. I took my .a files and stuck them in C:\Dev-Cpp\lib; I put my .h files in C:\Dev-Cpp\include; and I tossed my dlls in C:\Dev-Cpp\bin for good measure (still not sure if this part was necessary but what the hey).
As an extra good measure I explicitly stuck C:\Dev-Cpp\lib and C:\Dev-Cpp\include in the appropriate directories tabs in program options. This makes a rather redundant looking Makefile.win but it should work.
To test it I wrote out a small program:
include <libavcodec/avcodec.h>
include <libavformat/avformat.h>
int main(int argc, char *argv[]) {
av_register_all();
return 0;
}
Please note, that libavcodec and libavformat are folders inside of C:\Dev-Cpp\include and do contain the properly referenced files.
Now as you might imagine (assuming you know more about this than I do) I get a rather annoying compiler error:
main.o(.text+0x2b):main.cpp: undefined reference to `av_register_all()'
collect2: ld returned 1 exit status
Now since its ld complaining (not gcc) I'm guessing its finding the right .h file and its having a little problem finding the .a file (or dll, still not 100% on the difference there). So I took the time to explicitly include the .a files in the Parameters tab of project options under linker.
Same error.
So clearly I'm doing something wrong here, and I was hoping you all might know what.
I took the time to make sure that the function in question is in fact in libavformat/avformat.h, and I'm fairly sure the .a file is in C:\Dev-Cpp\lib\libavformat.a
Any ideas?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Interestingly they then link to another FAQ that shows them how to write the header to be mixed C/C++ compatible - so you have to wonder why they did not just do that! I suggest that you modify all the headers and 'contribute' them back to the project ;-). I can only imagine however that they and members of the anti-C++ league given their answer here: http://ffmpeg.mplayerhq.hu/faq.html#SEC39 . They have confused 'modular' with 'object oriented' it seems, and I cannot see how they think the of C for the Linux kernel can be used as justification for using it is this library.
I might also suggest that if you have a problem with a library, you check the library project rather than (or as well as) the tool project. On the other hand, I suspected that this was the problem before I found the FAQ (I 'site Googled' "C++" to find it). The problem with finding answers is that it is much easier when you know the answer! ;-)
The "quick fix" is to either compile the code as C not C++ or change the code as follows:
extern "C"
{
include <libavcodec/avcodec.h>
include <libavformat/avformat.h>
}
Note that since you have placed this library in a path specified by a -L switch (C:/Dev-Cpp/lib), rather than specifying "../../../Dev-Cpp/lib/libavformat.a" for example, you can use the short-hand -lavformat, and similarly for the other library components.
Personally I would not have put 'foriegn' libraries in the default library folder, lest you need to do a clean re-install. You can add your own library paths to a project should you wish. Interestingly you have done that even for the ones that are there by default - look at the log, they are there twice! The directories listed in Tools|Compiler options are used as defaults for all projects, the ones in Project|Project options, are additional.
The danger of using relative paths to files that are not located relative to your project file is that the project may not find the file if it is moved.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is a section in the thread titled "Please Read Before Posting a Question" on the compile log,including headers, and linking libraries that goes through the mechanics.
If you are still having issues, please post your "Basic 3", covered in the same "Please Read" thread.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In file included from main.cpp:2:
C:/Dev-Cpp/include/libavcodec/avcodec.h:2330: warning: `ImgReSampleContext' is deprecated (declared at C:/Dev-Cpp/include/libavcodec/avcodec.h:2324)
C:/Dev-Cpp/include/libavcodec/avcodec.h:2340: warning: `ImgReSampleContext' is deprecated (declared at C:/Dev-Cpp/include/libavcodec/avcodec.h:2324)
Ok, so I'm trying to include ffmpeg for decoding of mpeg4 files so I can play with the frame buffer (if you know of a lighter weight way of doing this feel free to let me know). I took the time to compile with minsys and I'd like to include my shiny new files and get on with the encoding or decoding of movies (I even shot a short clip to practice with).
So. I took my .a files and stuck them in C:\Dev-Cpp\lib; I put my .h files in C:\Dev-Cpp\include; and I tossed my dlls in C:\Dev-Cpp\bin for good measure (still not sure if this part was necessary but what the hey).
As an extra good measure I explicitly stuck C:\Dev-Cpp\lib and C:\Dev-Cpp\include in the appropriate directories tabs in program options. This makes a rather redundant looking Makefile.win but it should work.
To test it I wrote out a small program:
include <libavcodec/avcodec.h>
include <libavformat/avformat.h>
int main(int argc, char *argv[]) {
av_register_all();
return 0;
}
Please note, that libavcodec and libavformat are folders inside of C:\Dev-Cpp\include and do contain the properly referenced files.
Now as you might imagine (assuming you know more about this than I do) I get a rather annoying compiler error:
main.o(.text+0x2b):main.cpp: undefined reference to `av_register_all()'
collect2: ld returned 1 exit status
Now since its ld complaining (not gcc) I'm guessing its finding the right .h file and its having a little problem finding the .a file (or dll, still not 100% on the difference there). So I took the time to explicitly include the .a files in the Parameters tab of project options under linker.
Same error.
So clearly I'm doing something wrong here, and I was hoping you all might know what.
I took the time to make sure that the function in question is in fact in libavformat/avformat.h, and I'm fairly sure the .a file is in C:\Dev-Cpp\lib\libavformat.a
Any ideas?
The answer to your problem is this: http://ffmpeg.mplayerhq.hu/faq.html#SEC43
Interestingly they then link to another FAQ that shows them how to write the header to be mixed C/C++ compatible - so you have to wonder why they did not just do that! I suggest that you modify all the headers and 'contribute' them back to the project ;-). I can only imagine however that they and members of the anti-C++ league given their answer here: http://ffmpeg.mplayerhq.hu/faq.html#SEC39 . They have confused 'modular' with 'object oriented' it seems, and I cannot see how they think the of C for the Linux kernel can be used as justification for using it is this library.
I might also suggest that if you have a problem with a library, you check the library project rather than (or as well as) the tool project. On the other hand, I suspected that this was the problem before I found the FAQ (I 'site Googled' "C++" to find it). The problem with finding answers is that it is much easier when you know the answer! ;-)
The "quick fix" is to either compile the code as C not C++ or change the code as follows:
extern "C"
{
include <libavcodec/avcodec.h>
include <libavformat/avformat.h>
}
Note that since you have placed this library in a path specified by a -L switch (C:/Dev-Cpp/lib), rather than specifying "../../../Dev-Cpp/lib/libavformat.a" for example, you can use the short-hand -lavformat, and similarly for the other library components.
Personally I would not have put 'foriegn' libraries in the default library folder, lest you need to do a clean re-install. You can add your own library paths to a project should you wish. Interestingly you have done that even for the ones that are there by default - look at the log, they are there twice! The directories listed in Tools|Compiler options are used as defaults for all projects, the ones in Project|Project options, are additional.
The danger of using relative paths to files that are not located relative to your project file is that the project may not find the file if it is moved.
Clifford
There is a section in the thread titled "Please Read Before Posting a Question" on the compile log,including headers, and linking libraries that goes through the mechanics.
If you are still having issues, please post your "Basic 3", covered in the same "Please Read" thread.
Wayne
My mistake I thought I had copied the entire log and should have checked my message more thouroughly before posting
Here it is in full:
Compiler: Default compiler
Building Makefile: "C:\Users\Projects\Background\Makefile.win"
Executing make...
make.exe -f "C:\Users\Projects\Background\Makefile.win" all
g++.exe main.o -o "Background.exe" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/lib" ../../../Dev-Cpp/lib/libavformat.a ../../../Dev-Cpp/lib/libavutil.a ../../../Dev-Cpp/lib/libavcodec.a ../../../Dev-Cpp/lib/libavdevice.a ../../../Dev-Cpp/lib/libavformat.a ../../../Dev-Cpp/lib/libavicap32.a ../../../Dev-Cpp/lib/libavifil32.a
main.o(.text+0x2b):main.cpp: undefined reference to `av_register_all()'
collect2: ld returned 1 exit status
make.exe: *** [Background.exe] Error 1
Execution terminated
Although I do not think this is a problem with Dev-C++ itself, but rather my failing to use it, the version number is 4.9.9.2
I almost immediately realized my last post wasn't fully accurate either, as it was rebuilding from my current step instead of a clean project.
This is the full rebuild logs
Compiler: Default compiler
Building Makefile: "C:\Users\Projects\Background\Makefile.win"
Executing make...
make.exe -f "C:\Users\Projects\Background\Makefile.win" all
g++.exe main.o -o "Background.exe" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/lib" ../../../Dev-Cpp/lib/libavformat.a ../../../Dev-Cpp/lib/libavutil.a ../../../Dev-Cpp/lib/libavcodec.a ../../../Dev-Cpp/lib/libavdevice.a ../../../Dev-Cpp/lib/libavformat.a ../../../Dev-Cpp/lib/libavicap32.a ../../../Dev-Cpp/lib/libavifil32.a
main.o(.text+0x2b):main.cpp: undefined reference to `av_register_all()'
collect2: ld returned 1 exit status
make.exe: *** [Background.exe] Error 1
Execution terminated
I fail at basic copy/pasting....
Hopefully this will contain all the information you need, and if someone has the capability to delete my last post that would be helpful
Compiler: Default compiler
Building Makefile: "C:\Users\Projects\Background\Makefile.win"
Executing make clean
rm -f main.o Background.exe
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include"
In file included from main.cpp:2:
C:/Dev-Cpp/include/libavcodec/avcodec.h:2330: warning: `ImgReSampleContext' is deprecated (declared at C:/Dev-Cpp/include/libavcodec/avcodec.h:2324)
C:/Dev-Cpp/include/libavcodec/avcodec.h:2340: warning: `ImgReSampleContext' is deprecated (declared at C:/Dev-Cpp/include/libavcodec/avcodec.h:2324)
g++.exe main.o -o "Background.exe" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/lib" ../../../Dev-Cpp/lib/libavformat.a ../../../Dev-Cpp/lib/libavutil.a ../../../Dev-Cpp/lib/libavcodec.a ../../../Dev-Cpp/lib/libavdevice.a ../../../Dev-Cpp/lib/libavformat.a ../../../Dev-Cpp/lib/libavicap32.a ../../../Dev-Cpp/lib/libavifil32.a
main.o(.text+0x2b):main.cpp: undefined reference to `av_register_all()'
collect2: ld returned 1 exit status
make.exe: *** [Background.exe] Error 1
Execution terminated