Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sfeMovie installation and general building questions  (Read 5248 times)

0 Members and 1 Guest are viewing this topic.

Phalanx

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://gameandcode.com
sfeMovie installation and general building questions
« on: November 29, 2011, 05:19:46 am »
Being new to C++, I'm having trouble understanding how to compile, build and link to libraries. I was able to get SFML working more out of luck than actually understanding the core concepts. Now that I'm trying to install sfeMovie, I'm hitting a wall. I've been at this for a few hours, so I'll go over the steps I took, and would love any pointers in the right direction.

Step 1: dynamic linking

I grabbed the download here under binaries. Then, I added the libsfe-movie.dylib to Xcode under Target -> Summary -> Linked Frameworks and Libraries. I added the header file to the project as well. The project was built successfully, but threw a warning that the file format was not correct for the architecture being linked (x86_64). Changing my project to 32-bit got rid of the warning, but caused a fatal error when running.

Question 1: My assumption at this point is that my options are to compile SFML as 32-bit, or to compile sfeMovie as 64-bit. Is that correct, or are there other factors at play?

Step 2: Using build.sh

I took the approach of trying to compile sfeMovie on my own. I tried both the beta file and the current Git repo. In terminal, I placed:

Code: [Select]
sudo bash build.sh macosx -arch x86_64

For both attempts, a ton of errors were thrown. Sample of errors:

Code: [Select]
ormat/avformat.h:1374: error: expected declaration specifiers or ‘...’ before ‘int64_t’
./libavformat/avformat.h:1384: error: expected declaration specifiers or ‘...’ before ‘int64_t’
./libavformat/avformat.h:1393: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘av_gen_search’
./libavformat/avformat.h:1552: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘parse_date’
./libavformat/avformat.h:1558: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘av_gettime’
make: *** [libavdevice/alldevices.o] Error 1
*** an error occured, aborting.


Question 2: The only thing I could think of here is that I'm not using GCC. Is it used by default if I have it installed, or do I have to specify it? Or, is that a false lead, and is something else causing the errors?

Step 3: using CMake

I basically tried the same approach I used to install SFML. opened CMake, set the Git folder to the source path, tried both Debug and Release, and set the architecture to both Default and x86_64. Hit Configure again, and then generate. Went to the directory in terminal, ran a make clean and then a sudo make install. Sample errors are:

Code: [Select]
/Users/veeneck/GameDev/sfeMovieGit/src/Movie.cpp:402: error: ‘av_malloc’ cannot be used as a function
/Users/veeneck/GameDev/sfeMovieGit/src/Movie.cpp:421: error: ‘cerr’ is not a member of ‘std’
/Users/veeneck/GameDev/sfeMovieGit/src/Movie.cpp:421: error: ‘endl’ is not a member of ‘std’
/Users/veeneck/GameDev/sfeMovieGit/src/Movie.cpp: In member function ‘bool sfe::Movie::SaveFrame(AVPacket*)’:
/Users/veeneck/GameDev/sfeMovieGit/src/Movie.cpp:450: error: ‘cerr’ is not a member of ‘std’
make[2]: *** [CMakeFiles/sfe-movie.dir/src/Movie.cpp.o] Error 1
make[1]: *** [CMakeFiles/sfe-movie.dir/all] Error 2
make: *** [all] Error 2


Question 3: At this point, I'm just copy/pasting from the SFML install tutorial. Can someone explain the different concepts going on between step 2 and step 3?

And lastly, 2 more follow up questions.

Question 4: Any tips on other approaches I should try?

Question 5: Does anyone have a favorite article, tutorial or book on building, compiling, static linking, dynamic linking and frameworks?

Thanks a ton.
Wannabe Game Developer
Game & Code

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: sfeMovie installation and general building questions
« Reply #1 on: November 29, 2011, 01:42:06 pm »
Quote from: "Phalanx"
Question 1: My assumption at this point is that my options are to compile SFML as 32-bit, or to compile sfeMovie as 64-bit. Is that correct, or are there other factors at play?

The provided sfeMovie library is indeed 32-bit only. Thus you can build your program for Intel 32-bit only. For now universal (32-bit + 64-bit) sfeMovie libraries are not provided.


Quote from: "Phalanx"
Question 2: The only thing I could think of here is that I'm not using GCC. Is it used by default if I have it installed, or do I have to specify it? Or, is that a false lead, and is something else causing the errors?

I can't remember of such errors with a common build toolkit (GCC by default on Mac OS X) thus I would be interested in getting the full error log. Which Mac are you using? With which OS version?

The undefined cerr and endl symbols makes me think that your source code isn't clean or something is missing in your GCC installation.

I noticed you tried to add "-arch x86_64" when running build.sh. The script doesn't take such parameter, BUT at the beginning of the build.sh script, you can change the "macosx_arch" variable to fit your needs. Note that this will allow you to build in 64-bit only but still not a universal binary.

Quote from: "Phalanx"
Question 3: At this point, I'm just copy/pasting from the SFML install tutorial. Can someone explain the different concepts going on between step 2 and step 3?

The second step is building the FFmpeg library that sfeMovie uses. You can compile the different sfeMovie source files without building FFmpeg but the final library linking will fail. This is because sfeMovie uses functions from FFmpeg, and the final library doesn't contain all of the required symbols if the FFmpeg libraries aren't also included in the sfeMovie library.

Basically, you should just run the build.sh script (it will also run cmake and build sfeMovie once FFmpeg has been successfully built). Thus we need to find out why FFmpeg's compilation fails.

Quote from: "Phalanx"
Question 4: Any tips on other approaches I should try?

Finding why you can't build sfeMovie with the build.sh script should be the first point. And if you quickly need a working solution, keep the beta binaries and build in 32-bit only (note that the beta uses an older snapshot of the SFML 2.0 Git repository).
Want to play movies in your SFML application? Check out sfeMovie!

Phalanx

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://gameandcode.com
sfeMovie installation and general building questions
« Reply #2 on: November 30, 2011, 05:41:30 am »
Appreciate the detailed reply. I changed build.sh to use x86_64, and to use MacOSX10.6 instead of 10.5, and that allowed me to successfully build FFmpeg. So, progress was made. I'm still hitting a ton of errors though. Here is the full log:

http://pastebin.com/regwfbiB

I'm running Lion 10.7.1 on an i7 iMac.
Wannabe Game Developer
Game & Code

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
sfeMovie installation and general building questions
« Reply #3 on: November 30, 2011, 09:53:42 am »
I think you have no 10.5 SDK, that's why changing it to 10.6 fixed the first step (the 10.6 SDK isn't required to build for 64-bit). And this also explains why the compiler can't find any header, thus you should just replace 10.5 with 10.6 in the CMakeLists.txt file.
Want to play movies in your SFML application? Check out sfeMovie!

Phalanx

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://gameandcode.com
sfeMovie installation and general building questions
« Reply #4 on: November 30, 2011, 04:40:25 pm »
Ah, great. Starting to grasp CMake better. Changing that allowed the build to get to 100%, but it still threw an error when linking.

Code: [Select]
==================== sfeMovie compilation ====================

Running CMake...
cmake -G "Unix Makefiles" CMakeLists.txt
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/veeneck/GameDev/sfeMovieGit
Running make...
[ 16%] Building CXX object CMakeFiles/sfe-movie.dir/src/Movie.cpp.o
In file included from /Users/veeneck/GameDev/sfeMovieGit/deps/headers/libavformat/avformat.h:42,
                 from /Users/veeneck/GameDev/sfeMovieGit/src/Movie.cpp:27:
/Users/veeneck/GameDev/sfeMovieGit/deps/headers/libavcodec/avcodec.h:525: warning: attribute ignored in declaration of ‘enum AVLPCType’
/Users/veeneck/GameDev/sfeMovieGit/deps/headers/libavcodec/avcodec.h:525: warning: attribute for ‘enum AVLPCType’ must follow the ‘enum’ keyword
/Users/veeneck/GameDev/sfeMovieGit/src/Movie.cpp: In member function ‘bool sfe::Movie::OpenFromFile(const std::string&)’:
/Users/veeneck/GameDev/sfeMovieGit/src/Movie.cpp:86: warning: ‘av_open_input_file’ is deprecated (declared at /Users/veeneck/GameDev/sfeMovieGit/deps/headers/libavformat/avformat.h:1093)
/Users/veeneck/GameDev/sfeMovieGit/src/Movie.cpp:86: warning: ‘av_open_input_file’ is deprecated (declared at /Users/veeneck/GameDev/sfeMovieGit/deps/headers/libavformat/avformat.h:1093)
/Users/veeneck/GameDev/sfeMovieGit/src/Movie.cpp:106: warning: ‘dump_format’ is deprecated (declared at /Users/veeneck/GameDev/sfeMovieGit/deps/headers/libavformat/avformat.h:1535)
/Users/veeneck/GameDev/sfeMovieGit/src/Movie.cpp:106: warning: ‘dump_format’ is deprecated (declared at /Users/veeneck/GameDev/sfeMovieGit/deps/headers/libavformat/avformat.h:1535)
[ 33%] Building CXX object CMakeFiles/sfe-movie.dir/src/Movie_audio.cpp.o
In file included from /Users/veeneck/GameDev/sfeMovieGit/deps/headers/libavformat/avformat.h:42,
                 from /Users/veeneck/GameDev/sfeMovieGit/src/Movie_audio.h:31,
                 from /Users/veeneck/GameDev/sfeMovieGit/src/Movie_audio.cpp:25:
/Users/veeneck/GameDev/sfeMovieGit/deps/headers/libavcodec/avcodec.h:525: warning: attribute ignored in declaration of ‘enum AVLPCType’
/Users/veeneck/GameDev/sfeMovieGit/deps/headers/libavcodec/avcodec.h:525: warning: attribute for ‘enum AVLPCType’ must follow the ‘enum’ keyword
[ 50%] Building CXX object CMakeFiles/sfe-movie.dir/src/Movie_video.cpp.o
In file included from /Users/veeneck/GameDev/sfeMovieGit/deps/headers/libavformat/avformat.h:42,
                 from /Users/veeneck/GameDev/sfeMovieGit/src/Movie_video.h:29,
                 from /Users/veeneck/GameDev/sfeMovieGit/src/Movie_video.cpp:26:
/Users/veeneck/GameDev/sfeMovieGit/deps/headers/libavcodec/avcodec.h:525: warning: attribute ignored in declaration of ‘enum AVLPCType’
/Users/veeneck/GameDev/sfeMovieGit/deps/headers/libavcodec/avcodec.h:525: warning: attribute for ‘enum AVLPCType’ must follow the ‘enum’ keyword
[ 66%] Building CXX object CMakeFiles/sfe-movie.dir/src/utils.cpp.o
[ 83%] Building CXX object CMakeFiles/sfe-movie.dir/src/Condition.cpp.o
[100%] Building CXX object CMakeFiles/sfe-movie.dir/src/Unix/ConditionImpl.cpp.o
Linking CXX shared library libsfe-movie.dylib
ld: library not found for -lsfml-system.2.0
collect2: ld returned 1 exit status
make[2]: *** [libsfe-movie.dylib] Error 1
make[1]: *** [CMakeFiles/sfe-movie.dir/all] Error 2
make: *** [all] Error 2
*** an error occured, aborting.
Wannabe Game Developer
Game & Code

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
sfeMovie installation and general building questions
« Reply #5 on: November 30, 2011, 05:32:53 pm »
Uh.. I forgot to update the CMakeLists.txt file to use the SFML frameworks (there were previously only dylibs for SFML 2.0).

Thus, insert this at line 54 of CMakeLists.txt (within the "elseif (MACOSX)" block):
Code: [Select]

set (SFML_LIBRARIES "")
set (LINKER_FLAGS "${LINKER_FLAGS} -framework sfml-system -framework sfml-window -framework sfml-graphics -framework sfml-audio")


After that you should be able to get a libsfe-movie.dylib file.
Want to play movies in your SFML application? Check out sfeMovie!

Phalanx

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://gameandcode.com
sfeMovie installation and general building questions
« Reply #6 on: December 01, 2011, 03:34:20 am »
Awesome, that helped. I also had to change line 60 (62 after the change) from:

Code: [Select]
set (CMAKE_OSX_ARCHITECTURES "i386")

to

Code: [Select]
set (CMAKE_OSX_ARCHITECTURES "x86_64")

I'll start using it in a project now, and let you know how it goes. Thanks again.
Wannabe Game Developer
Game & Code

Phalanx

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://gameandcode.com
sfeMovie installation and general building questions
« Reply #7 on: December 01, 2011, 04:52:42 am »
Argh, so close. I was able to successfully link to the library. It builds and runs and the functions are all available. All that is left is ffmpeg errors. When I ran build.sh, I selected option 4 for all file formats. If I try to play any sample .avi I download, I get the following error:

Code: [Select]
[avi @ 0x102882600] max_analyze_duration 5000000 reached at 5000000
Movie_video::Initialize() - could not find any video decoder for this video format


If I try to play a .mov I created.

Code: [Select]
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1030b5200] Could not find codec parameters (Video: H.264, 1024x768, 2049 kb/s)
FFmpeg error: Operation not permitted


And if I use .mp4 (I believe this file isn't actually a .mp4, so error may just be indicating that).

Code: [Select]
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x101870200] max_analyze_duration 5000000 reached at 5000000
Movie_video::Initialize() - could not find any video decoder for this video format
Movie_audio::Initialize() - could not find any audio decoder for this audio format


I rebuilding everything and using a blank project, and I am receiving the same errors. There was no sample movie containing in the project download, so if anyone has a movie that definitely works, please link to it.
Wannabe Game Developer
Game & Code

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
sfeMovie installation and general building questions
« Reply #8 on: December 01, 2011, 07:18:28 am »
Hmm now I can't help you much. You must know that there are often several profiles for video codecs, and that FFmpeg only support some of these with the configuration you chose (maybe it can handle that better if you add the support for other external libraries in the FFmpeg configuration options but that is beyond my knowledge and it would force the use of the GPL instead of LGPL).

I can just tell you what worked fine for me: wmv sample video found on a default windows installation, movies created with QuickTime Player or iMovie and OGG and MP4 versions of the Sintel movie (freely downloadable).
Want to play movies in your SFML application? Check out sfeMovie!

Phalanx

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://gameandcode.com
sfeMovie installation and general building questions
« Reply #9 on: December 01, 2011, 07:26:31 am »
No worries. I'll try out more sample movies, and do some digging to try to narrow the problem down.
Wannabe Game Developer
Game & Code

Phalanx

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://gameandcode.com
sfeMovie installation and general building questions
« Reply #10 on: December 07, 2011, 07:52:28 am »
Alright, so I've tried going through everything again with no luck. Just want to go through my steps in case there are any obvious errors.

1. Open build.sh and cmakelists to change 10.5 to 10.6. Also change arch to x86_64, and add the two lines in previous reply.

2. Run build.sh. Selecting 1 or 4 for ffmpeg successfully completes, but there are a ton of warnings. First set encountered:

Code: [Select]
WARNING: pkg-config not found, library detection may fail.
HTML doc/developer.html
HTML doc/faq.html
HTML doc/general.html
HTML doc/libavfilter.html
CC libavdevice/alldevices.o
CC libavdevice/avdevice.o
AR libavdevice/libavdevice.a
CC libavfilter/af_anull.o
CC libavfilter/allfilters.o
CC libavfilter/asink_anullsink.o
CC libavfilter/asrc_anullsrc.o
CC libavfilter/avcodec.o
CC libavfilter/avfilter.o
CC libavfilter/avfiltergraph.o
CC libavfilter/defaults.o
libavfilter/defaults.c: In function ‘set_common_formats’:
libavfilter/defaults.c:207: warning: pointer of type ‘void *’ used in arithmetic
libavfilter/defaults.c:212: warning: pointer of type ‘void *’ used in arithmetic
CC libavfilter/drawutils.o


My question here would be whether or not you get warnings, or if it is a completely clean build?

3. Check that /product folder exists, and that the header and .dylib file are there.

4. Make clean and install to move the files to /usr/local

5. Add that .dylib file to linked libraries and Build phase -> copy files in Xcode.

6. Test movie throws errors mentioned above. The warnings are interesting though:

Code: [Select]
warning: Could not open OSO file /Users/veeneck/GameDev/sfeMovieGit/deps/ffmpeg-build/libswscale.a(rgb2rgb.o) to scan for pubtypes for objfile /usr/local/lib/libsfe-movie.dylib

It looks like it is trying to references files in the deps folder within the main folder I downloaded the source to, and not in /usr/local or the actual project directory. Could this be a permission issue, or is it supposed to look at the directory it was built in? Or, am I missing a step in adding dependencies?
Wannabe Game Developer
Game & Code

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
sfeMovie installation and general building questions
« Reply #11 on: December 07, 2011, 05:06:36 pm »
During FFmpeg's compilation I also get a lot of warnings, you shouldn't worry about these.

As for the OSO thing, it's information for the debugger only (see http://wiki.dwarfstd.org/index.php?title=Apple's_%22Lazy%22_DWARF_Scheme).

As for the "errors mentioned above", I suppose you're talking of the "could not find decoder" thing. I've no information on this point, the only idea I could tell you is to build ffplay (by manually building FFmpeg with ./configure && make) and see whether ffplay can correctly play your files. If it can, it's sfeMovie fault and I have to fix this (but I really have no time these days), otherwise it's FFmpeg or your video file's fault. For more details on building and using ffplay you'll have to find by yourself, I don't know much about it except that it's a basic player based on FFmpeg (and SDL if I remember well).
Want to play movies in your SFML application? Check out sfeMovie!

 

anything