Mingw doesn't find file strsafe.h while compiling OpenVC library - opencv

I want start playing with the OpenCV library, but I have a problem during the build process. I am on Windows 10 with the Mingw compiler. When I launch the command mingw32-make after a while, I get the following errors:
C:\Github\opencv\modules\videoio\src\cap_dshow.cpp:337:21: fatal error: strsafe.h: No such file or directory
#include <strsafe.h>
^
compilation terminated.
modules\videoio\CMakeFiles\opencv_videoio.dir\build.make:187: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_dshow.cpp.obj' failed
mingw32-make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_dshow.cpp.obj] Error 1
CMakeFiles\Makefile2:4340: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
mingw32-make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
The incriminated file is cap_dshow.cpp, and the compiler says that is missing the header file strsafe.h. Inside the folder C:\MinGW\include this file is not present and I don't know where to find this.
I've installed MinGW compiler (and other things) with a tool called "MinGW Installation Manager". With this tool I can install also other libraries, but I don't know if one of these contains the file strsafe.h.
My question is likely a duplicate of this, but the accepted answer has a broken link.

I have Microsoft SDK installed and found the strsafe.h file in "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin".
Adding "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin" to the Path system environment variable worked.

Related

ld can't find shared boost library in cmake build in a docker container

I'm working on a cmake project which linked to boost libraries. I want to link to shared boost_unit_test_framework and static the others. A part of cmakelists.txt as below:
set(Boost_USE_STATIC_LIBS on)
add_definitions(-DBOOST_TEST_DYN_LINK)
find_package (Boost REQUIRED COMPONENTS timer system OPTIONAL_COMPONENTS chrono)
find_library(boost_test boost_unit_test_framework /opt/boost/lib)
set (TEST test-suite)
add_executable (${TEST} ${Test_SRC})
message(STATUS "##########################${boost_test}")
target_link_libraries (${TEST} ${boost_test})
target_link_libraries (${TEST} ${Boost_LIBRARIES})
I tried to build it in a docker container, link errors reported:
/usr/bin/ld: cannot find -lboost_unit_test_framework
collect2: error: ld returned 1 exit status
make[2]: *** [QuantLib/test-suite/CMakeFiles/quantlib-test-suite.dir/build.make:1574: QuantLib/test-suite/quantlib-test-suite] Error 1
make[1]: *** [CMakeFiles/Makefile2:1267: QuantLib/test-suite/CMakeFiles/quantlib-test-suite.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
Some information:
1.My cmake version is 3.11.4; boost version is 1.74, installed under /opt/boost.
2.If I build it on a linux server, there is no error; If I build it in a docker continer, errors emited. The docker continer has almose same settings with the linux server: centos8.1/cmake3.11/boost1.74
3.${boost_test} message in cmakelists.txt show a full path: /opt/boost/lib/libboost_unit_test_framework.so
4.Make a soft link to libboost_unit_test_framework.so under /usr/lib can fix the error, but I don't want to change the container environment. I want to fix it in CMake.
5.Shared libs:
Any idea?

How to fix error with CMake while installing LuaDist on Windows 10

I've been trying to install Luadist, but an error with CMake always happens and in the end it doesn't install because of it.
This seems to be a common issue on Windows 10. I've followed the instructions from https://github.com/LuaDist/Repository/wiki/LuaDist%3A-Installation and https://github.com/LuaDist/Repository/wiki/Installation-of-System-Dependencies#microsoft-windows . I've tried uninstalling it and installing it again, but it didn't work. I tried installing Lua on the same drive as LuaDist, but it still doesn't work. I think the error might be because I also have LuaRocks installed, I don't know if they are compatible together.
[ 37%] Performing configure step for 'luafilesystem'
loading initial cache file C:/Users/User/_bootstrap/_bootstrap/tmp/config.cmake
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.15/Modules/CMakeMinGWFindMake.cmake:12 (message):
sh.exe was found in your PATH, here:
C:/Program Files/Git/usr/bin/sh.exe
For MinGW make to work correctly sh.exe must NOT be in your path.
Run cmake from a shell that does not have sh.exe in your PATH.
If you want to use a UNIX shell, then use MSYS Makefiles.
Call Stack (most recent call first):
CMakeLists.txt:7 (project)
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
CMakeFiles\luafilesystem.dir\build.make:106: recipe for target 'luafilesystem/src/luafilesystem-stamp/luafilesystem-configure' failed
mingw32-make.exe[3]: *** [luafilesystem/src/luafilesystem-stamp/luafilesystem-configure] Error 1
CMakeFiles\Makefile2:114: recipe for target 'CMakeFiles/luafilesystem.dir/all' failed
mingw32-make.exe[2]: *** [CMakeFiles/luafilesystem.dir/all] Error 2
CMakeFiles\Makefile2:175: recipe for target 'CMakeFiles/install.dir/rule' failed
mingw32-make.exe[1]: *** [CMakeFiles/install.dir/rule] Error 2
Makefile:156: recipe for target 'install' failed
mingw32-make.exe: *** [install] Error 2
## Bootstrap done, building LuaDist using LuaDist
'C:\Users\User\_bootstrap\_bootstrap\bin\luadist.exe' is not recognized as an internal or external command,
operable program or batch file.
## LuaDist is now built and can be found in C:\Users\User\_bootstrap\_install
At the end it says that LuaDist is built in C:\Users\User_bootstrap_intall , but that folder doens't exist after the installation.

OpenCV 2.4.13.4 Make Error with Mingw64-GCC-5.1

I am trying to compile OpenCV 2.4.13.4 with Mingw64-GCC-5.1 on Windows 10but I keep receiving the following error:
[ 95%] Generating perf_precomp.hpp.gch/opencv_perf_stitching_Release.gch
g++.exe: error: unrecognized command line option '-Wo-array-bounds'
modules\stitching\CMakeFiles\pch_Generate_opencv_perf_stitching.dir\build.make:61: recipe for target 'modules/stitching/perf_precomp.hpp.gch/opencv_perf_stitching_Release.gch' failed
mingw32-make[2]: *** [modules/stitching/perf_precomp.hpp.gch/opencv_perf_stitching_Release.gch] Error 1
CMakeFiles\Makefile2:6569: recipe for target 'modules/stitching/CMakeFiles/pch_Generate_opencv_perf_stitching.dir/all' failed
mingw32-make[1]: *** [modules/stitching/CMakeFiles/pch_Generate_opencv_perf_stitching.dir/all] Error 2
Please note that there is no typo here, -Wo-array-bounds is exactly the output I receive ( and not -Wno-array-bounds that google search suggests!). Any idea how to solve the problem? I searched for -Wo-array-bounds in the entire build folder to possibly change it to -Wno-array-bounds but I couldn't find this command line option in any file located in the build folder.

Adding Library to CMake on CLI

I'm trying to build OpenCV with CUDA support using Arch Linux's AUR. In their build configuration some options are passed to CMake, I have modified those to add CUDA features. Upon attempting compilation I get the following error:
[ 10%] Built target pch_Generate_opencv_reg
In file included from /home/meurer/Downloads/opencv-git/src/modules/cudacodec/opencv_cudacodec_pch_dephelp.cxx:1:0:
/home/meurer/Downloads/opencv-git/src/opencv/modules/cudacodec/src/precomp.hpp:59:14: fatal error: dynlink_nvcuvid.h: No such file or directory
#include <dynlink_nvcuvid.h>
^~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [modules/cudacodec/CMakeFiles/opencv_cudacodec_pch_dephelp.dir/build.make:63: modules/cudacodec/CMakeFiles/opencv_cudacodec_pch_dephelp.dir/opencv_cudacodec_pch_dephelp.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:6834: modules/cudacodec/CMakeFiles/opencv_cudacodec_pch_dephelp.dir/all] Error 2
I searched my filesystem and found the rogue header file in /usr/include/nvidia-sdk/dynlink_nvcuvid.h. Due to how AUR works, I believe I can only configure CMake via command line options (See links 1, 2 under _cmakeopts=...).
What argument can I pass to CMake to make it search for the appropriate libraries under the aforementioned directory, as well as the ones it already uses?

fatal error: 'clang-c/Index.h' file not found on OSX 10.9.4

I was trying to install clang_complete on OSX 10.9.4. However while running make I get the following error:
[ 66%] Building CXX object CMakeFiles/clic_add.dir/clic_add.cpp.o
/Users/bharat/Desktop/clang_indexer/clic_add.cpp:5:10: fatal error: 'clang-c/Index.h'
file not found
#include <clang-c/Index.h>
^
1 error generated.
I have clang, llvm-g++ and llvm-gcc. How do I resolve this error?
You can download source code for clang
svn checkout http://llvm.org/svn/llvm-project/cfe/trunk
The header should be in the include/clang-c folders, you can edit the cmake file and pass in the location of the header in the CPP flags (-I)
cmake file would be here:-
ycm/CMakeFiles/ycm_core.dir/flags.make

Resources