anthwlock / untrunc

Restore a truncated mp4/mov. Improved version of ponchio/untrunc
GNU General Public License v2.0
1.9k stars 182 forks source link

Build on CentOS 7 error #43

Closed pavelety closed 4 years ago

pavelety commented 4 years ago

Hi, guys! I was really amused that I found your maintained fork, because we've been using main untrunc repo build for few years and it worked not bad (on CentOS 6 and then on CentOS 7), but it's always good to have even more. Thanks for a great job! I have an error during the build I'm trying to build your fork using these steps:

yum install -y unzip
wget https://github.com/anthwlock/untrunc/archive/master.zip
unzip master.zip

Found some ready libav binaries:

wget http://www.nosuchhost.net/~cheese/fedora/packages/epel-7/x86_64/cheese-release-7-1.noarch.rpm
rpm -Uvh cheese-release*rpm
yum instal -y install libavformat-devel libavcodec-devel libavutil-devel

cd untrunc-master Simple make instantly fails with:

untrunc:
ffmpeg: shared
g++ -MMD -MP -DUNTR_VERSION=\"\" -std=c++11 -D_FILE_OFFSET_BITS=64 -g -o .build_shared/src/track.o -c src/track.cpp
src/track.cpp:32:32: fatal error: libavcodec/avcodec.h: No such file or directory
 #include <libavcodec/avcodec.h>
                                ^
compilation terminated.
make: *** [.build_shared/src/track.o] Error 1

Didn't find any instructions to include lib paths, but found that I need to change Makefile script to make it work on CentOS 7. nano Makefile Removed wget attribute --show-progress. It’s not supported in CentOS 7 Then make FF_VER=3.3.9 And it compiled pretty long with a few warnings (I think, it's not related). And completely failed on this:

ffmpeg: 3.3.9

g++ -MMD -MP -DUNTR_VERSION=\"\" -I./ffmpeg-3.3.9 -std=c++11 -D_FILE_OFFSET_BITS=64 -g -o .build_3.3.9/src/track.o -c src/track.cpp
In file included from /usr/include/c++/4.8.2/algorithm:62:0,
                 from src/common.h:9,
                 from src/codec.h:7,
                 from src/track.h:26,
                 from src/track.cpp:21:
/usr/include/c++/4.8.2/bits/stl_algo.h: In instantiation of '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::tuple<int, double, int>*, std::vector<std::tuple<int, double, int> > >; _Tp = std::tuple<int, double, int>; _Compare = Track::genPatternPerm()::__lambda0]':
/usr/include/c++/4.8.2/bits/stl_algo.h:2296:78:   required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::tuple<int, double, int>*, std::vector<std::tuple<int, double, int> > >; _Compare = Track::genPatternPerm()::__lambda0]'
/usr/include/c++/4.8.2/bits/stl_algo.h:2337:62:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::tuple<int, double, int>*, std::vector<std::tuple<int, double, int> > >; _Size = long int; _Compare = Track::genPatternPerm()::__lambda0]'
/usr/include/c++/4.8.2/bits/stl_algo.h:5499:44:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::tuple<int, double, int>*, std::vector<std::tuple<int, double, int> > >; _Compare = Track::genPatternPerm()::__lambda0]'
src/track.cpp:338:3:   required from here
/usr/include/c++/4.8.2/bits/stl_algo.h:2263:35: error: no match for call to '(Track::genPatternPerm()::__lambda0) (std::tuple<int, double, int>&, const std::tuple<int, double, int>&)'
    while (__comp(*__first, __pivot))
                                   ^
src/track.cpp:335:34: note: candidates are:
  sort(perm.begin(), perm.end(), [](tuple_t& a, tuple_t& b) {
                                  ^
In file included from /usr/include/c++/4.8.2/algorithm:62:0,
                 from src/common.h:9,
                 from src/codec.h:7,
                 from src/track.h:26,
                 from src/track.cpp:21:
/usr/include/c++/4.8.2/bits/stl_algo.h:2263:35: note: bool (*)(tuple_t&, tuple_t&) {aka bool (*)(std::tuple<int, double, int>&, std::tuple<int, double, int>&)} <conversion>
    while (__comp(*__first, __pivot))
                                   ^
/usr/include/c++/4.8.2/bits/stl_algo.h:2263:35: note:   candidate expects 3 arguments, 3 provided
src/track.cpp:335:58: note: Track::genPatternPerm()::__lambda0
  sort(perm.begin(), perm.end(), [](tuple_t& a, tuple_t& b) {
                                                          ^
src/track.cpp:335:58: note:   no known conversion for argument 2 from 'const std::tuple<int, double, int>' to 'tuple_t& {aka std::tuple<int, double, int>&}'
In file included from /usr/include/c++/4.8.2/algorithm:62:0,
                 from src/common.h:9,
                 from src/codec.h:7,
                 from src/track.h:26,
                 from src/track.cpp:21:
/usr/include/c++/4.8.2/bits/stl_algo.h:2266:34: error: no match for call to '(Track::genPatternPerm()::__lambda0) (const std::tuple<int, double, int>&, std::tuple<int, double, int>&)'
    while (__comp(__pivot, *__last))
                                  ^
src/track.cpp:335:34: note: candidates are:
  sort(perm.begin(), perm.end(), [](tuple_t& a, tuple_t& b) {
                                  ^
In file included from /usr/include/c++/4.8.2/algorithm:62:0,
                 from src/common.h:9,
                 from src/codec.h:7,
                 from src/track.h:26,
                 from src/track.cpp:21:
/usr/include/c++/4.8.2/bits/stl_algo.h:2266:34: note: bool (*)(tuple_t&, tuple_t&) {aka bool (*)(std::tuple<int, double, int>&, std::tuple<int, double, int>&)} <conversion>
    while (__comp(__pivot, *__last))
                                  ^
/usr/include/c++/4.8.2/bits/stl_algo.h:2266:34: note:   candidate expects 3 arguments, 3 provided
src/track.cpp:335:58: note: Track::genPatternPerm()::__lambda0
  sort(perm.begin(), perm.end(), [](tuple_t& a, tuple_t& b) {
                                                          ^
src/track.cpp:335:58: note:   no known conversion for argument 1 from 'const std::tuple<int, double, int>' to 'tuple_t& {aka std::tuple<int, double, int>&}'
make: *** [.build_3.3.9/src/track.o] Error 1

Complete logs

Please provide some further steps to fix the build and I will send you complete instructions to install this on CentOS (to add this in your readme).

anthwlock commented 4 years ago

src/track.cpp:335:58: note: no known conversion for argument 1 from 'const std::tuple<int, double, int>' to 'tuple_t& {aka std::tuple<int, double, int>&}'

Hmm.. Maybe adding const to the lambda parameters helps? https://github.com/anthwlock/untrunc/blob/8ea50b280cf955ae613e7996da8058e123e08a4b/src/track.cpp#L335

src/track.cpp:32:32: fatal error: libavcodec/avcodec.h: No such file or directory

Where do the packages you meantion install libavcodec/avcodec.h to? Can you try this guide?

anthwlock commented 4 years ago

@pavelety So does it compile now?

pavelety commented 4 years ago

Dear @anthwlock , how should I exactly change this line? I'm not very familiar with C++. ffmpeg and libs were previously installed from yum repo here: /usr/include/ffmpeg/libavcodec/avcodec.h But when I specify make FF_VER=3.3.9 it downloads separate version in the current folder: /opt/untrunc-master/ffmpeg-3.3.9/libavcodec/avcodec.h

anthwlock commented 4 years ago

how should I exactly

before:

sort(perm.begin(), perm.end(), [](tuple_t& a, tuple_t& b) { 

after:

sort(perm.begin(), perm.end(), [](const tuple_t& a, const tuple_t& b) {

ffmpeg and libs were previously installed from yum repo here: /usr/include/ffmpeg/libavcodec/avcodec.h

This looks wrong. I think it should be /usr/include/libavcodec/avcodec.h. Can you do a symlink and then check if the compilation without the FF_VER argument works?

I have a serious question: Why do you use a linux distro where even installing crucial packages like ffmpeg is a pain (not in it's official repos)?

anthwlock commented 4 years ago

@pavelety Any progress? Maybe it is more elegant to export CPATH=/usr/include/ffmpeg/ instead of symlinking all the libav* directories.

anthwlock commented 4 years ago

https://github.com/anthwlock/untrunc#centos-7