I am on arch and made the mistake of upgrading.
Before I could build bacward-cpp, now I get the following error:
../libraries/backward-cpp/backward.hpp:1357:10: error: ‘bfd_get_section_flags’ was not declared in this scope; did you mean ‘bfd_set_section_flags’?
1357 | if ((bfd_get_section_flags(fobj.handle.get(), section) & SEC_ALLOC) == 0)
| ^~~~~~~~~~~~~~~~~~~~~
| bfd_set_section_flags
../libraries/backward-cpp/backward.hpp:1360:24: error: ‘bfd_get_section_vma’ was not declared in this scope; did you mean ‘bfd_set_section_vma’?
1360 | bfd_vma sec_addr = bfd_get_section_vma(fobj.handle.get(), section);
| ^~~~~~~~~~~~~~~~~~~
| bfd_set_section_vma
../libraries/backward-cpp/backward.hpp:1361:26: error: ‘bfd_get_section_size’ was not declared in this scope; did you mean ‘bfd_set_section_size’?
1361 | bfd_size_type size = bfd_get_section_size(section);
| ^~~~~~~~~~~~~~~~~~~~
| bfd_set_section_size
make[1]: *** [VulkanEngine.make:233: obj/Debug/VulkanDebugging.o] Error 1
make: *** [Makefile:30: VulkanEngine] Error 2
I am linking with both lbdf and ldl, by doing -lbfd -ldl as arguments to g++. I am also doing #define BACKWARD_HAS_BFD 1 before including the header as per the documentation.
I am at a loss.
The corresponding macros of binutils changed slightly.
You have to drop the _get from the section macros and remove the fobj.handle.get() parameter manually: bfd_get_section_flags(fobj.handle.get(), section) to bfd_section_flags(section).
Related
I made a project with SDL2 under Windows.
When I try to compile it on Linux, these errors occur:
reilbas#reilbas:~/C/a/Labyrinthe-3D-main$ g++ -o test -I include src/*.cpp $(sdl2-config --cflags --libs)
src/Affichage.cpp: In member function ‘void Affichage::drawRect(float, float, float, float, SDL_Color&)’:
src/Affichage.cpp:110:17: error: ‘SDL_Vertex’ was not declared in this scope; did you mean ‘SDL_mutex’?
110 | std::vector<SDL_Vertex> triUi1 = {
| ^~~~~~~~~~
| SDL_mutex
src/Affichage.cpp:110:27: error: template argument 1 is invalid
110 | std::vector<SDL_Vertex> triUi1 = {
| ^
src/Affichage.cpp:110:27: error: template argument 2 is invalid
src/Affichage.cpp:110:29: error: scalar object ‘triUi1’ requires one element in initializer
110 | std::vector<SDL_Vertex> triUi1 = {
| ^~~~~~
src/Affichage.cpp:115:27: error: template argument 2 is invalid
115 | std::vector<SDL_Vertex> triUi2 = {
| ^
src/Affichage.cpp:115:29: error: scalar object ‘triUi2’ requires one element in initializer
115 | std::vector<SDL_Vertex> triUi2 = {
| ^~~~~~
src/Affichage.cpp:120:5: error: ‘SDL_RenderGeometry’ was not declared in this scope; did you mean ‘SDL_RenderCopy’?
120 | SDL_RenderGeometry(renderer, nullptr, triUi1.data(), triUi1.size(), nullptr, 0);
| ^~~~~~~~~~~~~~~~~~
| SDL_RenderCopy
src/Affichage.cpp: In member function ‘void Affichage::displayTri(std::vector<triangle>)’:
src/Affichage.cpp:146:21: error: ‘SDL_Vertex’ was not declared in this scope; did you mean ‘SDL_mutex’?
146 | std::vector<SDL_Vertex> verts = {
| ^~~~~~~~~~
| SDL_mutex
src/Affichage.cpp:146:31: error: template argument 1 is invalid
146 | std::vector<SDL_Vertex> verts = {
| ^
src/Affichage.cpp:146:31: error: template argument 2 is invalid
src/Affichage.cpp:146:33: error: scalar object ‘verts’ requires one element in initializer
146 | std::vector<SDL_Vertex> verts = {
| ^~~~~
src/Affichage.cpp:151:9: error: ‘SDL_RenderGeometry’ was not declared in this scope; did you mean ‘SDL_RenderCopy’?
151 | SDL_RenderGeometry( renderer, nullptr, verts.data(), verts.size(), nullptr, 0);
| ^~~~~~~~~~~~~~~~~~
| SDL_RenderCopy
src/AllMath.cpp: In static member function ‘static int AllMath::triangleClipAgainstPlane(vec3d, vec3d, triangle&, triangle&, triangle&)’:
src/AllMath.cpp:254:1: warning: control reaches end of non-void function [-Wreturn-type]
254 | }
| ^
I installed SDL2 with apt:
$ sudo apt-get install libsdl2
SDL_RenderGeometry() & friends were introduced in SDL 2.0.18:
Added SDL_RenderGeometry() and SDL_RenderGeometryRaw() to allow rendering of arbitrary shapes using the SDL 2D render API
...so make sure you're using that version or higher.
SDL 2.0.18 was released in late 2021 so distros like Ubuntu 20.04 that ship older versions of SDL won't have those newer functions.
The newest version of OpenCV(4) does not come with createsamples feature for creating HAAR CASCADE files. It's just mind boggling. To attain this feature, there are two solutions: 1) Download an older version on a different machine or 2) Compile createsamples.cpp I am choosing item two as anyone can settle for kluge anytime. Item two comes with many errors that look the same as shown below:
harry#harry-usedmachine:/usr/include/opencv4$ sudo g++ createsamples.cpp
[sudo] password for harry:
In file included from createsamples.cpp:48:
/usr/include/opencv4/opencv2/core.hpp:2523:16: error: ‘FileStorage’ has not been declared
2523 | void write(FileStorage& fs) const;
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp:2573:15: error: ‘FileStorage’ has not been declared
2573 | void save(FileStorage& fs) const;
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp:2577:21: error: ‘FileStorage’ does not name a type
2577 | void load(const FileStorage& node);
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp:3088:24: error: ‘FileStorage’ has not been declared
3088 | virtual void write(FileStorage& fs) const { CV_UNUSED(fs); }
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp:3093:34: error: ‘FileStorage’ was not declared in this scope
3093 | CV_WRAP void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp:3093:45: error: template argument 1 is invalid
3093 | CV_WRAP void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
| ^
/usr/include/opencv4/opencv2/core.hpp:3172:22: error: ‘FileStorage’ has not been declared
3172 | void writeFormat(FileStorage& fs) const;
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp: In static member function ‘static cv::Ptr<_Tp> cv::Algorithm::load(const String&, const String&)’:
/usr/include/opencv4/opencv2/core.hpp:3135:9: error: ‘FileStorage’ was not declared in this scope
3135 | FileStorage fs(filename, FileStorage::READ);
| ^~~~~~~~~~~
In file included from /usr/include/opencv4/opencv2/core.hpp:55,
from createsamples.cpp:48:
/usr/include/opencv4/opencv2/core.hpp:3136:19: error: ‘fs’ was not declared in this scope; did you mean ‘ffs’?
3136 | CV_Assert(fs.isOpened());
| ^~
/usr/include/opencv4/opencv2/core/base.hpp:342:38: note: in definition of macro ‘CV_Assert’
342 | #define CV_Assert( expr ) do { if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0)
| ^~~~
In file included from createsamples.cpp:48:
/usr/include/opencv4/opencv2/core.hpp:3137:41: error: ‘fs’ was not declared in this scope; did you mean ‘ffs’?
3137 | FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
| ^~
| ffs
/usr/include/opencv4/opencv2/core.hpp:3137:18: error: ‘fn’ has incomplete type
3137 | FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
| ^~
In file included from /usr/include/opencv4/opencv2/core/base.hpp:58,
from /usr/include/opencv4/opencv2/core.hpp:55,
from createsamples.cpp:48:
/usr/include/opencv4/opencv2/core/cvstd.hpp:150:18: note: forward declaration of ‘class cv::FileNode’
150 | class CV_EXPORTS FileNode; //for string constructor from FileNode
| ^~~~~~~~
In file included from createsamples.cpp:48:
/usr/include/opencv4/opencv2/core.hpp: In static member function ‘static cv::Ptr<_Tp> cv::Algorithm::loadFromString(const String&, const String&)’:
/usr/include/opencv4/opencv2/core.hpp:3156:9: error: ‘FileStorage’ was not declared in this scope
3156 | FileStorage fs(strModel, FileStorage::READ + FileStorage::MEMORY);
| ^~~~~~~~~~~
/usr/include/opencv4/opencv2/core.hpp:3157:41: error: ‘fs’ was not declared in this scope; did you mean ‘ffs’?
3157 | FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
| ^~
| ffs
Many of the errors are coming from core.hpp and createsample.cpp. createsample.cpp is here: https://github.com/opencv/opencv/blob/master/apps/createsamples/createsamples.cpp
and core.hpp is here: https://github.com/opencv/opencv/blob/master/modules/core/include/opencv2/core.hpp
Would much appreciate any insights on fixing these errors.
Easiest way seems to be downloading an older opencv version source code like https://github.com/opencv/opencv/archive/2.4.13.6.zip and extract it to any location. In that folder perform
mkdir build
cd build
cmake ..
make
cd bin
there you will find the binaries of opencv_createsamples, opencv_traincascade etc.
It is NOT necessary to install that old version (that would happen if you use 'make install' ), just use your currently installed opencv build of any version for all tasks and if you need to create sample or train a cascade, use this build at the directory where you copy it to.
i try to create some small project on windows, but when i try to build this with cmake there are many errors occured. On linux this build up successfully. When i create dummy project with CMake all work. This is my folder structure:
extern
googletest
tests
...
CMakeLists.txt
...
CMakeLists.txt
Root CMakeLists.txt:
# Setup cmake minimal required version
cmake_minimum_required(VERSION 3.10)
# Declare project
project(mobile_speaker_driver)
# Change c++ standard
set(CMAKE_CXX_STANDARD 17)
# Adding googletest to project
option(PACKAGE_TESTS "Build the tests" ON)
if(PACKAGE_TESTS)
enable_testing()
include(GoogleTest)
add_subdirectory(tests)
endif()
# Add source files to driver library
if (WIN32)
set(SOURCE_FILES apps/main.cpp src/AudioDriver.cpp src/AudioDriverWindows.cpp)
elseif (UNIX)
set(SOURCE_FILES apps/main.cpp src/AudioDriver.cpp src/AudioDriverLinux.cpp)
endif (WIN32)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
Tests CMakeLists.txt:
set(TESTBINARY ${PROJECT_NAME}_test)
add_subdirectory("${PROJECT_SOURCE_DIR}/extern/googletest" "extern/googletest")
add_executable(${TESTBINARY} main.cpp AudioDriverTest.cpp)
target_link_libraries(${TESTBINARY} gtest gtest_main)
Errors:
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::StrCaseCmp(const char*, const char*)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h:1985:10: error: '_stricmp' was not declared in this scope; did you mean 'strncmp'?
1985 | return _stricmp(s1, s2);
| ^~~~~~~~
| strncmp
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'char* testing::internal::posix::StrDup(const char*)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h:1987:47: error: '_strdup' was not declared in this scope
1987 | inline char* StrDup(const char* src) { return _strdup(src); }
| ^~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::FileNo(FILE*)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h:1995:40: error: '_fileno' was not declared in this scope; did you mean 'file'?
1995 | inline int FileNo(FILE* file) { return _fileno(file); }
| ^~~~~~~
| file
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'FILE* testing::internal::posix::FDOpen(int, const char*)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/include/gtest/internal/gtest-port.h:2072:56: error: 'fdopen' was not declared in this scope; did you mean 'fopen'?
2072 | inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
| ^~~~~~
| fopen
In file included from D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-all.cc:41:
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest.cc: In static member function 'static bool testing::internal::String::CaseInsensitiveWideCStringEquals(const wchar_t*, const wchar_t*)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest.cc:2077:10: error: '_wcsicmp' was not declared in this scope; did you mean 'wcsncmp'?
2077 | return _wcsicmp(lhs, rhs) == 0;
| ^~~~~~~~
| wcsncmp
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest.cc: In member function 'int testing::UnitTest::Run()':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest.cc:5253:21: error: '_OUT_TO_STDERR' was not declared in this scope
5253 | _set_error_mode(_OUT_TO_STDERR);
| ^~~~~~~~~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest.cc:5253:5: error: '_set_error_mode' was not declared in this scope
5253 | _set_error_mode(_OUT_TO_STDERR);
| ^~~~~~~~~~~~~~~
In file included from D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-all.cc:42:
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc: In function 'void testing::internal::DeathTestAbort(const string&)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:296:5: error: '_exit' was not declared in this scope; did you mean '_cexit'?
296 | _exit(1);
| ^~~~~
| _cexit
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc: In member function 'virtual void testing::internal::DeathTestImpl::Abort(testing::internal::DeathTest::AbortReason)':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:527:3: error: '_exit' was not declared in this scope; did you mean '_cexit'?
527 | _exit(1); // Exits w/o any normal exit hooks (we were supposed to crash)
| ^~~~~
| _cexit
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc: In member function 'virtual testing::internal::DeathTest::TestRole testing::internal::WindowsDeathTest::AssumeRole()':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:771:24: error: '_MAX_PATH' was not declared in this scope; did you mean 'MAX_PATH'?
771 | char executable_path[_MAX_PATH + 1]; // NOLINT
| ^~~~~~~~~
| MAX_PATH
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:773:65: error: 'executable_path' was not declared in this scope
773 | executable_path,
| ^~~~~~~~~~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:308:38: note: in definition of macro 'GTEST_DEATH_TEST_CHECK_'
308 | if (!::testing::internal::IsTrue(expression)) { \
| ^~~~~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:797:11: error: 'executable_path' was not declared in this scope
797 | executable_path, const_cast<char*>(command_line.c_str()),
| ^~~~~~~~~~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-death-test.cc:308:38: note: in definition of macro 'GTEST_DEATH_TEST_CHECK_'
308 | if (!::testing::internal::IsTrue(expression)) { \
| ^~~~~~~~~~
In file included from D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-all.cc:43:
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-filepath.cc: In static member function 'static testing::internal::FilePath testing::internal::FilePath::GetCurrentDir()':
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-filepath.cc:49:26: error: '_MAX_PATH' was not declared in this scope; did you mean 'MAX_PATH'?
49 | # define GTEST_PATH_MAX_ _MAX_PATH
| ^~~~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-filepath.cc:101:12: note: in expansion of macro 'GTEST_PATH_MAX_'
101 | char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
| ^~~~~~~~~~~~~~~
D:/Projects/mobile-speaker-driver/extern/googletest/googletest/src/gtest-filepath.cc:102:27: error: 'cwd' was not declared in this scope
102 | return FilePath(_getcwd(cwd, sizeof(cwd)) == nullptr ? "" : cwd);
| ^~~
make.exe[2]: *** [tests/extern/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Ошибка 1
make.exe[1]: *** [tests/extern/googletest/googletest/CMakeFiles/gtest.dir/all] Ошибка 2
make.exe: *** [all] Ошибка 2
The problem is occured because i force build googletest with c++17 flags. Just place CMAKE_CXX_STANDARD after googletest include in main CMakeLists.txt.
I am pretty new to Linux and I am having problems integrating an external software into my program. I am following the instructions on integrating a couple of lines that show step by step integration of the software they are listed in the Application development section here.
I got through some of the instruction [I removed Jansson] and I have separately tested the package independent and build it thus it works outside. The problem is when intergrating after make install command it shows these errors:
Scanning dependencies of target g4sipm_sample
[ 63%] Building CXX object externals/g4sipm/sample/CMakeFiles/g4sipm_sample.dir/src/ActionInitialization.cc.o
/home/abhinab1/goddess/source/externals/g4sipm/sample/src/ActionInitialization.cc: In member function ‘virtual void ActionInitialization::Build() const’:
/home/abhinab1/goddess/source/externals/g4sipm/sample/src/ActionInitialization.cc:45:38: error: no matching function for call to ‘RunAction::RunAction(const string&)’
45 | SetUserAction(new RunAction(filename));
| ^
In file included from /home/abhinab1/goddess/source/externals/g4sipm/sample/src/ActionInitialization.cc:21:
/home/abhinab1/goddess/source/Simulation/include/DataProcessing/RunAction.hh:35:2: note: candidate: ‘RunAction::RunAction(SimulationMessenger*)’
35 | RunAction( SimulationMessenger * simulationMessenger /**< class storing and providing variables which are needed in different parts of the simulation. */
| ^~~~~~~~~
/home/abhinab1/goddess/source/Simulation/include/DataProcessing/RunAction.hh:35:35: note: no known conversion for argument 1 from ‘const string’ {aka ‘const std::__cxx11::basic_string<char>’} to ‘SimulationMessenger*’
35 | RunAction( SimulationMessenger * simulationMessenger /**< class storing and providing variables which are needed in different parts of the simulation. */
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/home/abhinab1/goddess/source/Simulation/include/DataProcessing/RunAction.hh:26:7: note: candidate: ‘constexpr RunAction::RunAction(const RunAction&)’
26 | class RunAction : public G4UserRunAction
| ^~~~~~~~~
/home/abhinab1/goddess/source/Simulation/include/DataProcessing/RunAction.hh:26:7: note: no known conversion for argument 1 from ‘const string’ {aka ‘const std::__cxx11::basic_string<char>’} to ‘const RunAction&’
/home/abhinab1/goddess/source/externals/g4sipm/sample/src/ActionInitialization.cc:46:20: error: no matching function for call to ‘EventAction::EventAction()’
46 | SetUserAction(new EventAction);
| ^~~~~~~~~~~
In file included from /home/abhinab1/goddess/source/externals/g4sipm/sample/src/ActionInitialization.cc:20:
/home/abhinab1/goddess/source/Simulation/include/DataProcessing/EventAction.hh:38:2: note: candidate: ‘EventAction::EventAction(SimulationMessenger*)’
38 | EventAction( SimulationMessenger * simulationMessenger /**< class storing and providing variables which are needed in different parts of the simulation. */
| ^~~~~~~~~~~
/home/abhinab1/goddess/source/Simulation/include/DataProcessing/EventAction.hh:38:2: note: candidate expects 1 argument, 0 provided
/home/abhinab1/goddess/source/Simulation/include/DataProcessing/EventAction.hh:30:7: note: candidate: ‘constexpr EventAction::EventAction(const EventAction&)’
30 | class EventAction : public G4UserEventAction
| ^~~~~~~~~~~
/home/abhinab1/goddess/source/Simulation/include/DataProcessing/EventAction.hh:30:7: note: candidate expects 1 argument, 0 provided
/home/abhinab1/goddess/source/externals/g4sipm/sample/src/ActionInitialization.cc:52:57: error: ‘const class DetectorConstruction’ has no member named ‘getSipmModel’
52 | ParticleSourceMessenger::getInstance()->setA(detector->getSipmModel()->getPitch());
| ^~~~~~~~~~~~
/home/abhinab1/goddess/source/externals/g4sipm/sample/src/ActionInitialization.cc:53:57: error: ‘const class DetectorConstruction’ has no member named ‘getSipmModel’
53 | ParticleSourceMessenger::getInstance()->setB(detector->getSipmModel()->getPitch());
Here are the changes that I made in my CMakeFile.txt:
add_subdirectory(externals/g4sipm)
include_directories(externals/g4sipm/g4sipm/include)
include_directories(externals/g4sipm/externals/gtest/include)
# Export sims data
include_directories(externals/g4sipm/sample/include)
set(LIBS ${LIBS} boost_program_options g4sipm g4sipm_sample boost_date_time jansson)
target_link_libraries(RunSimulation g4sipm boost_date_time)
I tried contacting the project lead however it seems they have all moved on from the project. Any help and suggestions would be greatly appreciated, thank you!
EDIT: I made a small mistake as I added
include_directories(externals/g4sipm/sample)
in the Checklist.txt which I removed.
The errors are reduced but not gone I have put the updated terminal output above.
I installed ffmpeg according to this article. ffmpeg installation was ok.
Now I build opencv with ffmpeg support and I have some errors.
The errors are
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp:1484:21: error: ‘CODEC_FLAG_GLOBAL_HEADER’ was not declared in this scope
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
^
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp: In function ‘int icv_av_write_frame_FFMPEG(AVFormatContext*, AVStream*, uint8_t*, uint32_t, AVFrame*)’:
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp:1512:30: error: ‘AVFMT_RAWPICTURE’ was not declared in this scope
if (oc->oformat->flags & AVFMT_RAWPICTURE) {
^
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘void CvVideoWriter_FFMPEG::close()’:
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp:1686:35: error: ‘AVFMT_RAWPICTURE’ was not declared in this scope
if( (oc->oformat->flags & AVFMT_RAWPICTURE) == 0 )
^
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvVideoWriter_FFMPEG::open(const char*, int, double, int, int, bool)’:
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp:1920:32: error: ‘AVFMT_RAWPICTURE’ was not declared in this scope
if (!(oc->oformat->flags & AVFMT_RAWPICTURE)) {
^
In file included from /home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg.cpp:45:0:
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp: In static member function ‘static AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext*, AVCodecID, int, int, int, double, AVPixelFormat)’:
/home/coie/Softwares/Libraries/opencv-2.4.13.3/modules/highgui/src/cap_ffmpeg_impl.hpp:2214:25: error: ‘CODEC_FLAG_GLOBAL_HEADER’ was not declared in this scope
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
^
modules/highgui/CMakeFiles/opencv_highgui.dir/build.make:230: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o' failed
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o] Error 1
CMakeFiles/Makefile2:2349: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/all' failed
What could be wrong?
My solution is to grep the missing defines (2 in total) from FFmpeg by using grep -r which leads to the following code found in libavcodec/avcodec.h:
#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
#define AVFMT_RAWPICTURE 0x0020
Copy and paste it to the top of:
opencv-3.3.0/modules/videoio/src/cap_ffmpeg_impl.hpp
Compile and everything works even with the latest sources
Easiest change for the CODEC_FLAG_GLOBAL_HEADER is to change it to AV_CODEC_FLAG_GLOBAL_HEADER, it was redefined in a newer version.
Note the "AV_" in front
in opencv:0/2.4 there is no modules/videoio directory! to get that old version (2.4.13-r3) to compile with newest media-video/ffmpeg on gentoo (4.1.3) I had to add above changes to modules/highgui/src/cap_ffmpeg_api.hpp with this
patch:
--- opencv-2.4.13/modules/highgui/src/cap_ffmpeg_api.hpp 2019-05-27 13:28:05.736339890 +0200
+++ opencv-2.4.13-new/modules/highgui/src/cap_ffmpeg_api.hpp 2019-05-27 13:27:48.787198507 +0200
## -12,6 +12,10 ##
#define OPENCV_FFMPEG_API
#endif
+#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
+#define CODEC_FLAG_GLOBAL_HEADER
AV_CODEC_FLAG_GLOBAL_HEADER
+#define AVFMT_RAWPICTURE 0x0020
+
enum
{
CV_FFMPEG_CAP_PROP_POS_MSEC=0,
(i.e. I created the path and file /etc/portage/patches/media-libs/opencv-2.4.13-r3/old-ffmpeg.patch with that contents.)
in defense to gentoo, I should mention, the new media-libs/opencv:0/3.4.1 is also available, as is the old media-video/ffmpeg-3.4.5, so I could alternatively also play around with masking out versions or file a bug for developers to do that for me...