Building OpenCV using makefile throwing error? - c++

I was trying to setup OpenCV environment using MingW64 and visual studio code,
Work done so far
Installed and set environment CMake
Installed OpenCV 4.5.2
OpenCV Makefile generation
using CMake Build from source(openCV directory)
specified the generator for the project
configured the compiler type and makefile type
Enabled precompiled header
Confusing part
when I entered the command mingw32-make for compilation in directory where the makefile is generated
It worked until 67% after that:
[ 67%] Built target pch_Generate_opencv_test_dnn
Scanning dependencies of target opencv_test_dnn
[ 67%] Building CXX object modules/dnn/CMakeFiles/opencv_test_dnn.dir/test/npy_blob.cpp.obj
In file included from <command-line>:0:0:
D:/opencv/build/modules/dnn/test_precomp.hpp:50:10: fatal error: test_common.hpp: No such file or directory
#include "test_common.hpp"
^~~~~~~~~~~~~~~~~
compilation terminated.
mingw32-make[2]: *** [modules\dnn\CMakeFiles\opencv_test_dnn.dir\build.make:82: modules/dnn/CMakeFiles/opencv_test_dnn.dir/test/npy_blob.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:3429: modules/dnn/CMakeFiles/opencv_test_dnn.dir/all] Error 2
mingw32-make: *** [Makefile:181: all] Error 2
thank you

Related

No rule to make target `/usr/bin/openssl/lib', needed by `examples/example_ssl'. Stop

I am trying to build a C++ library(https://github.com/ipkn/crow) on macOS 12.0.1(Monterey).
Since I am learning C++ since yesterday, I have no clue what to do next with error message like this:
ld: warning: dylib (/usr/local/lib/libboost_system-mt.dylib) was built for newer macOS version (12.0) than being linked (11.3)
ld: warning: dylib (/usr/local/lib/libboost_thread-mt.dylib) was built for newer macOS version (12.0) than being linked (11.3)
[ 19%] Built target example_chat
Consolidate compiler generated dependencies of target example_ssl
[ 23%] Building CXX object examples/CMakeFiles/example_ssl.dir/ssl/example_ssl.cpp.o
make[2]: *** No rule to make target `/usr/bin/openssl/lib', needed by `examples/example_ssl'. Stop.
make[1]: *** [examples/CMakeFiles/example_ssl.dir/all] Error 2
make: *** [all] Error 2
/usr/bin/openssl is actually the result when which openssl is executed
My question: As a toddler in C++, how to debug an error message like this? What I have to learn as prerequisites ?

Building TBB on Windows using MingW & Cmake

Hey I'm trying to build TBB on my Windows computer using MinGW & CMake. (gcc,,g++, ..)
I have already tried using the premade binaries but I keep getting undefined reference issues.
My cmake for the project I'm trying to import it in looks as following:
find_package(TBB REQUIRED tbb)
target_link_libraries(projectName PRIVATE ${TBB_IMPORTED_TARGETS})
I use the source code of https://github.com/oneapi-src/oneTBB/releases/tag/v2021.3.0 (latest)
and I make a build dir and cd into it and execute:
cmake .. -G "MinGW Makefiles"
followed by:
cmake --build .
also tried:
mingw32-make
Both result into
[ 1%] Building CXX object src/tbb/CMakeFiles/tbb.dir/address_waiter.cpp.obj
In file included from c:\users\refactor\downloads\onetbb-2021.3.0\onetbb-2021.3.0\include\oneapi\tbb\detail\_utils.h:26,
from C:\Users\Refactor\Downloads\oneTBB-2021.3.0\oneTBB-2021.3.0\src\tbb\address_waiter.cpp:17:
c:\users\refactor\downloads\onetbb-2021.3.0\onetbb-2021.3.0\include\oneapi\tbb\detail\_machine.h:67: error: ignoring '#pragma intrinsic ' [-Werror=unknown-pragmas]
67 | #pragma intrinsic(_mm_mfence)
|
compilation terminated due to -Wfatal-errors.
cc1plus.exe: all warnings being treated as errors
mingw32-make[2]: *** [src\tbb\CMakeFiles\tbb.dir\build.make:76: src/tbb/CMakeFiles/tbb.dir/address_waiter.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:454: src/tbb/CMakeFiles/tbb.dir/all] Error 2
mingw32-make: *** [makefile:165: all] Error 2```
As mentioned in the comments there are issues building with MinGW with the latest versions of TBB.
The last version of TBB I was able to build was 2020.0 using this command (replace intel64 with ia32 for 32-bit):
mingw32-make compiler=gcc arch=intel64 runtime=mingw tbb tbbmalloc CPLUS="g++ -static-libstdc++ -static-libgcc"

How can I run many C++ source files in one CLion project?

I am using CLion as an IDE. When I create a project a main.cpp is automatically added. I would like to add 30-40 cpp files in a project and keep them as one project. Basically, I just wanna create many .cpp files in one folder and make CLion run them. I can do this in Pycharm by simply creating a project and add as many .py files as I want. But when I want to do this on CLion I got an error. Is it possible to add many .cpp files in a project in CLion, if yes, how can I do that?
An error could be seen in the below. I added a second.cpp to the project and run and this error message appears.
====================[ Build | trial | Debug ]===================================
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/mertsaner/CLionProjects/trial/cmake-build-debug --target trial -- -j 6
Scanning dependencies of target trial
[ 66%] Building CXX object CMakeFiles/trial.dir/main.cpp.o
[ 66%] Building CXX object CMakeFiles/trial.dir/second.cpp.o
[100%] Linking CXX executable trial
duplicate symbol '_main' in:
CMakeFiles/trial.dir/main.cpp.o
CMakeFiles/trial.dir/second.cpp.o
ld: 1 duplicate symbol for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [trial] Error 1
make[2]: *** [CMakeFiles/trial.dir/all] Error 2
make[1]: *** [CMakeFiles/trial.dir/rule] Error 2
make: *** [trial] Error 2
Clion uses Cmake. If you want to create multiple executable files for eg with names (ex1.cpp, ex2.cpp. ex3.cpp) in one directory, you will do something like this in the CMake file of your directory.
cmake_minimum_required(VERSION 3.18)
project(some_project)
set(CMAKE_CXX_STANDARD 20)
add_executable(executable1 ex1.cpp)
add_executable(executable2 ex2.cpp)
add_executable(executable3 ex3.cpp)
and so on..

Clion: How to configure clion when Opening existing folder there is no debug and run menu?

I'm using CLion 2021.1.1 version. I'm a new user. I've done some cpp programs on codeblocks. But Whenever I open an existing folder the files are showing but there is no debug option. It says Add configuration. There is no run option. I've added MingW in buil, execution, Deployment -> Toolchains-> mingw but still it says add configuration. I've close it open new projects in CPP but still getting add configuration. How can open the existing folder and it has many cpp files that I can run each and every cpp file. How can achieve this?
sometimes I get this error:
CMake Error at C:/Program Files/JetBrains/CLion 2021.1.1/bin/cmake/win/share/cmake-3.19/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"C:/MinGW/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: O:/1.Fourth Semester/Programming/Algorithm/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command(s):C:/MinGW/bin/mingw32-make.exe cmTC_d8b71/fast && C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_d8b71.dir\build.make CMakeFiles/cmTC_d8b71.dir/build
mingw32-make.exe[1]: Entering directory 'O:/1.Fourth Semester/Programming/Algorithm/cmake-build-debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_d8b71.dir/testCCompiler.c.obj
C:\MinGW\bin\gcc.exe -o CMakeFiles\cmTC_d8b71.dir\testCCompiler.c.obj -c "O:\1.Fourth Semester\Programming\Algorithm\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c"
CMakeFiles\cmTC_d8b71.dir\build.make:83: recipe for target 'CMakeFiles/cmTC_d8b71.dir/testCCompiler.c.obj' failed
mingw32-make.exe[1]: *** [CMakeFiles/cmTC_d8b71.dir/testCCompiler.c.obj] Error 1
mingw32-make.exe[1]: Leaving directory 'O:/1.Fourth Semester/Programming/Algorithm/cmake-build-debug/CMakeFiles/CMakeTmp'
Makefile:139: recipe for target 'cmTC_d8b71/fast' failed
mingw32-make.exe: *** [cmTC_d8b71/fast] Error 2
CMake will not be able to correctly generate this project
Someone help, please

certain headers arent being found, even though I've included them. Aside from using quotes, how can I fix this?

Ive downloaded the SDL2 library using brew install SDL2 but when I am trying to compile melonDS for Mac, I keep banging my head against the wall of the annoying error of
bash-3.2$ make
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/bigman/melonDS/build
[ 1%] Building CXX object CMakeFiles/melonDS.dir/src/libui_sdl/main.cpp.o
/Users/bigman/melonDS/src/libui_sdl/main.cpp:24:10: fatal error:
'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>
^~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/melonDS.dir/src/libui_sdl/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/melonDS.dir/all] Error 2
make: *** [all] Error 2
bash-3.2$
I've uninstalled, reinstalled, tried to use compiler flags in the makefile (which did't work because the project uses cmake) but to no avail. Any other reccomendations would be great.