h4tr3d / avcpp

C++ wrapper for FFmpeg
Other
459 stars 80 forks source link

Compiling problems of the examples #60

Open marcoippolito opened 4 years ago

marcoippolito commented 4 years ago

In Ubuntu 18.04.4 Desktop I installed avcpp following these indications: https://github.com/h4tr3d/avcpp#ubuntu-and-linux-mint

(base) marco@pc01:~$ git clone --recurse-submodules https://github.com/h4tr3d/avcpp.git avcpp-
git
Cloning into 'avcpp-git'...
remote: Enumerating objects: 45, done.
remote: Counting objects: 100% (45/45), done.
remote: Compressing objects: 100% (35/35), done.
remote: Total 1605 (delta 16), reused 14 (delta 6), pack-reused 1560
Receiving objects: 100% (1605/1605), 523.42 KiB | 1.56 MiB/s, done.
Resolving deltas: 100% (1110/1110), done.
Submodule 'catch2' (https://github.com/catchorg/Catch2.git) registered for path 'catch2'
Cloning into '/home/marco/avcpp-git/catch2'...
remote: Enumerating objects: 110, done.
remote: Counting objects: 100% (110/110), done.
remote: Compressing objects: 100% (92/92), done.
remote: Total 26279 (delta 34), reused 43 (delta 18), pack-reused 26169
Receiving objects: 100% (26279/26279), 15.91 MiB | 9.42 MiB/s, done.
Resolving deltas: 100% (18294/18294), done.
Submodule path 'catch2': checked out 'f0b7b0ca119d8cf58c2b89dea663f921dbdbd332'

(base) marco@pc01:~/avcpp-git$ mkdir build
(base) marco@pc01:~/avcpp-git$ cd build
(base) marco@pc01:~/avcpp-git/build$ cmake ..
-- The CXX compiler identification is GNU 9.2.1
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Checking for module 'libavcodec'
--   Found libavcodec, version 58.54.100
-- Checking for module 'libavformat'
--   Found libavformat, version 58.29.100
-- Checking for module 'libavdevice'
--   Found libavdevice, version 58.8.100
-- Checking for module 'libavutil'
--   Found libavutil, version 56.31.100
-- Checking for module 'libavfilter'
--   Found libavfilter, version 7.57.100
-- Checking for module 'libswscale'
--   Found libswscale, version 5.5.100
-- Checking for module 'libpostproc'
--   Found libpostproc, version 55.5.100
-- Checking for module 'libswresample'
--   Found libswresample, version 3.5.100
-- Found FFmpeg: /usr/lib/x86_64-linux-gnu/libavcodec.so;/usr/lib/x86_64-linux-gnu/libavformat.so;
/usr/lib/x86_64-linux-gnu/libavutil.so;/usr/lib/x86_64-linux-gnu/libavdevice.so;/usr/lib/x86_64-linux-
gnu$
-- /home/marco/avcpp-git/catch2/contrib
-- Configuring done
-- Generating done
-- Build files have been written to: /home/marco/avcpp-git/build
(base) marco@pc01:~/avcpp-git/build$ sudo make -j8
Scanning dependencies of target test_main
Scanning dependencies of target avcpp
Scanning dependencies of target avcpp_static
[  1%] Building CXX object tests/CMakeFiles/test_main.dir/test-main.cpp.o
[  4%] Building CXX object src/CMakeFiles/avcpp.dir/averror.cpp.o
....
[100%] Linking CXX executable test_executor
/usr/bin/ld: warning: libavutil.so.55, needed by //usr/lib/x86_64-linux-gnu/libchromaprint.so.1, may 
conflict with libavutil.so.56
[100%] Built target test_executor
(base) marco@pc01:~/avcpp-git/build$

(base) marco@pc01:~/avcpp-git/build$ sudo make install
[ 33%] Built target avcpp_static
[ 67%] Built target avcpp
[ 70%] Built target api2-decode
[ 72%] Built target api2-decode-audio
[ 75%] Built target api2-scale-video
[ 78%] Built target api2-remux
[ 81%] Built target api2-decode-rasample-audio
[ 83%] Built target api2-decode-encode-audio
[ 86%] Built target api2-demux-seek
[ 89%] Built target api2-decode-encode-video
[ 91%] Built target api2-dict-basic
[ 94%] Built target api2-timestamp
[ 97%] Built target test_main
[100%] Built target test_executor
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/libavcpp.so
-- Installing: /usr/local/lib/libavcpp.a
-- Installing: /usr/local/include/avcpp
-- Installing: /usr/local/include/avcpp/stream.h
-- Installing: /usr/local/include/avcpp/packet.h
-- Installing: /usr/local/include/avcpp/dictionary.h
-- Installing: /usr/local/include/avcpp/sampleformat.h
-- Installing: /usr/local/include/avcpp/pixelformat.h
-- Installing: /usr/local/include/avcpp/codeccontext.h
-- Installing: /usr/local/include/avcpp/rational.h
-- Installing: /usr/local/include/avcpp/timestamp.h
-- Installing: /usr/local/include/avcpp/ffmpeg.h
-- Installing: /usr/local/include/avcpp/frame.h
-- Installing: /usr/local/include/avcpp/videorescaler.h
-- Installing: /usr/local/include/avcpp/avtime.h
-- Installing: /usr/local/include/avcpp/filters
-- Installing: /usr/local/include/avcpp/filters/filterpad.h
-- Installing: /usr/local/include/avcpp/filters/filtercontext.h
-- Installing: /usr/local/include/avcpp/filters/buffersink.h
-- Installing: /usr/local/include/avcpp/filters/filter.h
-- Installing: /usr/local/include/avcpp/filters/buffersrc.h
-- Installing: /usr/local/include/avcpp/filters/filtergraph.h
-- Installing: /usr/local/include/avcpp/formatcontext.h
-- Installing: /usr/local/include/avcpp/av.h
-- Installing: /usr/local/include/avcpp/avutils.h
-- Installing: /usr/local/include/avcpp/audioresampler.h
-- Installing: /usr/local/include/avcpp/linkedlistutils.h
-- Installing: /usr/local/include/avcpp/format.h
-- Installing: /usr/local/include/avcpp/avlog.h
-- Installing: /usr/local/include/avcpp/codec.h
-- Installing: /usr/local/include/avcpp/rect.h
-- Installing: /usr/local/include/avcpp/averror.h
-- Installing: /usr/local/lib/pkgconfig/libavcpp.pc
-- Installing: /usr/local/lib/cmake/Catch2/Catch2Targets.cmake
-- Up-to-date: /usr/local/include
-- Installing: /usr/local/include/catch2
-- Installing: /usr/local/include/catch2/catch.hpp
-- Installing: /usr/local/include/catch2/catch_reporter_teamcity.hpp
-- Installing: /usr/local/include/catch2/catch_reporter_automake.hpp
-- Installing: /usr/local/include/catch2/catch_reporter_tap.hpp
-- Installing: /usr/local/lib/cmake/Catch2/Catch2Config.cmake
-- Installing: /usr/local/lib/cmake/Catch2/Catch2ConfigVersion.cmake
-- Installing: /usr/local/share/doc/Catch2
-- Installing: /usr/local/share/doc/Catch2/ci-and-misc.md
-- Installing: /usr/local/share/doc/Catch2/configuration.md
-- Installing: /usr/local/share/doc/Catch2/limitations.md
-- Installing: /usr/local/share/doc/Catch2/release-notes.md
-- Installing: /usr/local/share/doc/Catch2/test-cases-and-sections.md
-- Installing: /usr/local/share/doc/Catch2/command-line.md
-- Installing: /usr/local/share/doc/Catch2/tutorial.md
-- Installing: /usr/local/share/doc/Catch2/logging.md
-- Installing: /usr/local/share/doc/Catch2/opensource-users.md
-- Installing: /usr/local/share/doc/Catch2/test-fixtures.md
-- Installing: /usr/local/share/doc/Catch2/release-process.md
-- Installing: /usr/local/share/doc/Catch2/cmake-integration.md
-- Installing: /usr/local/share/doc/Catch2/benchmarks.md
-- Installing: /usr/local/share/doc/Catch2/slow-compiles.md
-- Installing: /usr/local/share/doc/Catch2/own-main.md
-- Installing: /usr/local/share/doc/Catch2/assertions.md
-- Installing: /usr/local/share/doc/Catch2/deprecations.md
-- Installing: /usr/local/share/doc/Catch2/reporters.md
-- Installing: /usr/local/share/doc/Catch2/event-listeners.md
-- Installing: /usr/local/share/doc/Catch2/generators.md
-- Installing: /usr/local/share/doc/Catch2/commercial-users.md
-- Installing: /usr/local/share/doc/Catch2/tostring.md
-- Installing: /usr/local/share/doc/Catch2/Readme.md
-- Installing: /usr/local/share/doc/Catch2/other-macros.md
-- Installing: /usr/local/share/doc/Catch2/matchers.md
-- Installing: /usr/local/share/doc/Catch2/list-of-examples.md
-- Installing: /usr/local/share/doc/Catch2/why-catch.md
-- Installing: /usr/local/share/doc/Catch2/contributing.md
-- Installing: /usr/local/lib/cmake/Catch2/ParseAndAddCatchTests.cmake
-- Installing: /usr/local/lib/cmake/Catch2/Catch.cmake
-- Installing: /usr/local/lib/cmake/Catch2/CatchAddTests.cmake
-- Installing: /usr/local/share/Catch2/gdbinit
-- Installing: /usr/local/share/Catch2/lldbinit
-- Installing: /usr/local/share/pkgconfig/catch2.pc

(base) marco@pc01:/usr/local/include$ sudo mv avcpp av

But when trying to compile some examples I get "No such file or directory":

(base) marco@pc01:~/avcpp-git/example/test-basic$ g++ -std=c++17 -I /usr/local/include/av/ av-
main.cpp -L /usr/local/lib/libavcpp.so -o av-main
av-main.cpp:7:10: fatal error: av/containerformat.h: No such file or directory
    7 | #include "av/containerformat.h"
av-main.cpp:8:10: fatal error: av/container.h: No such file or directory
av-main.cpp:10:10: fatal error: av/streamcoder.h: No such file or directory

The same problem for another example:

(base) marco@pc01:~/avcpp-git/example/sample-view$ g++ -std=c++17 -I /usr/local/include/av/    
av-view.cpp -L /usr/local/lib/libavcpp.so -o av-view
av-view.cpp:5:10: fatal error: SDL/SDL.h: No such file or directory
    5 | #include <SDL/SDL.h>
       |          ^~~~~~~~~~~

(base) marco@pc01:~/avcpp-git/example/sample-view$ cd build
(base) marco@pc01:~/avcpp-git/example/sample-view/build$ cmake .. 
CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- The C compiler identification is GNU 9.2.1
-- The CXX compiler identification is GNU 9.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:13 (pkg_search_module):
  Unknown CMake command "pkg_search_module".

CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.16)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!
See also "/home/marco/avcpp-git/example/sample-view/build/CMakeFiles/CMakeOutput.log".

How to solve the problem?

h4tr3d commented 4 years ago

sample-transcode, sample-view and test-basic keeps only for historical reason. Refer to api2-samples.

And main issue, that you tries to build only with AvCpp as dependency. But FFmpeg one also needed.

Try last version (some changes was not committed for a three month...)

Also, samples can be compiled out of tree now. You can use samples CMakeLists.txt as a reference.

pkg-config file libavcpp.pc still has problems. Additional testing is needed.