Building TBB on Windows using MingW & Cmake - c++

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"

Related

a problem with the raylib installation on linux

im using Peppermint 10 an ubuntu based distro
so i did the following commands here and everything went well until this
(the input)
cmake -DBUILD_SHARED_LIBS=ON ..
(the output)
-- Testing if -Werror=pointer-arith can be used -- compiles
-- Testing if -Werror=implicit-function-declaration can be used -- compiles
-- Testing if -fno-strict-aliasing can be used -- compiles
-- Using raylib's GLFW
-- Using X11 for window creation
-- Audio Backend: miniaudio
-- Building raylib shared library
-- Generated build type: Debug
-- Compiling with the flags:
-- PLATFORM=PLATFORM_DESKTOP
-- GRAPHICS=GRAPHICS_API_OPENGL_33
-- Building examples is enabled
-- Testing if -std=c11 can be used -- compiles
-- Configuring done
CMake Error at src/CMakeLists.txt:57 (add_library):
Error evaluating generator expression:
$<TARGET_OBJECTS:glfw>
Objects of target "glfw" referenced but is not an OBJECT library.
CMake Error: CMake can not determine linker language for target: raylib
CMake Error: Cannot determine link language for target "raylib".
-- Generating done
-- Build files have been written to: /home/anas/raylib/build
how do i even fix these cmake errors?
but then i ignored these thought it was normal but when i tried to do the following command
(the command aka the input)
make
(the output)
[ 7%] Built target glfw
make[2]: *** No rule to make target 'raylib/CMakeFiles/raylib.dir/build'. Stop.
CMakeFiles/Makefile2:87: recipe for target 'raylib/CMakeFiles/raylib.dir/all' failed
make[1]: *** [raylib/CMakeFiles/raylib.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
it shows the same thing when i try sudo make install
help
i still dont know what is the problem here
btw im following the wiki here
Do this:
sudo apt install g++
sudo apt install cmake (should be in version 3.11 or higher)
download to your project folder ex. 'new-game' folder those three files from https://github.com/RobLoach/raylib-cpp/tree/master/projects/CMake (main.cpp, README.md, CMakeLists.txt)
then cd new-game && mkdir build && cd build && cmake .. && make
run ./raylib-cpp-example

Building OpenCV using makefile throwing error?

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

Building ASSIMP with MinGW causes file too big error

I am building ASSIMP using cmake and mingw-w64 on windows 10 and it gives me "file too big" errors while creating the object code. I tried using MinGW and MinGW-w64 and both give me the same error. I am using the default settings, I configure the project with cmake, generate the makefile and then run mingw32-make. Is there some kind of flag I can set to fix this?
Compiler:
g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0
Here is the output:
[ 59%] Building CXX object code/CMakeFiles/assimp.dir/Importer/StepFile/StepFileImporter.cpp.obj
[ 60%] Building CXX object code/CMakeFiles/assimp.dir/Importer/StepFile/StepFileGen1.cpp.obj
C:/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/as.exe:
CMakeFiles\assimp.dir\Importer\StepFile\StepFileGen1.cpp.obj: section .xdata$_ZNSt10_Head_baseILy0EPN6Assimp8StepFile29directed_dimensional_locationELb0EE7_M_headERKS4_:
string table overflow at offset 10000029
C:\Users\ANDREW~1.NOT\AppData\Local\Temp\ccwwseVM.s: Assembler messages:
C:\Users\ANDREW~1.NOT\AppData\Local\Temp\ccwwseVM.s: Fatal error: can't close CMakeFiles\assimp.dir\Importer\StepFile\StepFileGen1.cpp.obj: File too big
mingw32-make[2]: *** [code\CMakeFiles\assimp.dir\build.make:2485: code/CMakeFiles/assimp.dir/Importer/StepFile/StepFileGen1.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:274: code/CMakeFiles/assimp.dir/all] Error 2
mingw32-make: *** [Makefile:129: all] Error 2
EDIT: I was using the master branch of Assimp from github, which has newer experimental features. I downloaded an older release version and I did not get the same errors.
This error is fixed by assimp itself https://github.com/assimp/assimp/issues/2406 Which version do you use?
What worked for me :
Go into the CMakeLists.txt and add:
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-O3")
Then compile with some options off:
cmake .. -G "Unix Makefiles" -DASSIMP_BUILD_ASSIMP_TOOLS=OFF -DASSIMP_BUILD_TESTS=OFF
make -j4 && make install
It worked for 5.0.0-rc1 and 5.0.1 too.

Error while building OpenCV 3.1.0 with extra modules on OS X Mavericks

I am a beginner in OpenCV, using OpenCV 3.1.0 (downloaded from OpenCV.org) with Mac OS X 10.9.5.
I was trying to run a code which needs contrib.hpp, then I found the extra modules from Github. There is a command from the page:
$ cd <opencv_build_directory>
$ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory>
$ make -j5
Everything was successful before I did make, it shows an error of no matching function for call to 'calibrateCamera' :
[ 92%] Building CXX object modules/aruco/CMakeFiles/opencv_aruco.dir/src/aruco.cpp.o
/Users/Youko/downloads/opencv_contrib-master/modules/aruco/src/aruco.cpp:1583:12: error:
no matching function for call to 'calibrateCamera'
return calibrateCamera(processedObjectPoints, processedImagePoints, ...
^~~~~~~~~~~~~~~
/Users/Youko/downloads/opencv-3.1.0/modules/calib3d/include/opencv2/calib3d.hpp:844:21: note:
candidate function not viable: requires at most 9 arguments, but 12 were
provided
CV_EXPORTS_W double calibrateCamera( InputArrayOfArrays objectPoints,
^
1 error generated.
make[2]: *** [modules/aruco/CMakeFiles/opencv_aruco.dir/src/aruco.cpp.o] Error 1
make[1]: *** [modules/aruco/CMakeFiles/opencv_aruco.dir/all] Error 2
make: *** [all] Error 2
In the case of I wanna keep the version of Mac OSX, I was thinking of change the version of OpenCV, so I've downloaded OpenCV from Github, and tried to install the OpenCV with following command (it was the same way as how I've installed OpenCV 3.1.0 successfully):
$ cd <opencv_source_directory>
$ mkdir release
$ cd release
$ cmake -G "Unix Makefiles" ..
$ make
$ sudo make install
But there is another problem when I tried make:
[ 44%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_mjpeg_decoder.cpp.o
[ 44%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_avfoundation_mac.mm.o
[ 44%] Linking CXX shared library ../../lib/libopencv_videoio.dylib
ld: framework not found CoreImage
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libopencv_videoio.3.1.0.dylib] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2
I thought maybe there was something wrong with cmake, so I tried the following command as well but the same error occurred with make:
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
I've googled for the problem and it seems like I must need the QuartzCore, but most of people said it should be included in the Xcode (I am using Xcode 6.2 btw). I tried both ways to figure it out but I still have no idea why I can't build the extra modules. (I think the most weird problem is that I cannot install OpenCV cloned from Github, but I just wanna show I tried this way but it wasn't successful FYI.)
I'd be most grateful for any help and suggestions!

Can not compile google test with MinGW on Windows

I tried to compile google test framework with MinGW on Windows following instructions from this post, but I got errors when executing make:
[ 25%] Building CXX object CMakeFiles/gtest.dir/src/gtest-all.cc.obj
In file included from d:/downloads/googletest-master/googletest/src/gtest-all.cc:45:0:
D:/downloads/googletest-master/googletest/src/gtest-port.cc: In static member function 'static void testing::internal::ThreadLocalRegistryImpl::StartWatcherThreadFor(DWORD)':
D:/downloads/googletest-master/googletest/src/gtest-port.cc:495:21: error: '::OpenThread' has not been declared
HANDLE thread = ::OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION,
^
make[2]: *** [CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Error 1
make[1]: *** [CMakeFiles/gtest.dir/all] Error 2
make: *** [all] Error 2
Please help. I tried:
cmake -G "MSYS Makefiles" --with-pthreads=no
But got:
CMake Error: The source directory "D:/downloads/googletest-master/googletest/--with-pthreads=no" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
Thanks for answers.
cmake -G "MSYS Makefiles" --with-pthreads=no
I don't think --with-pthreads=no is a valid cmake option. CMake tries to interpret it as the source directory. Remove that option. I think google test needs pthreads anyways, that is why OpenThread is not declared, because it depends on pthreads.
If you're not using the MSYS shell, try to use the "MinGW Makefiles" generator for cmake.
cmake -G "MinGW Makefiles"
Then run make.