OpenCV 3.4.3 compiling with MinGW-64 8.1.0 using CMake...New Issue

asked 2018-09-21 11:38:02 -0500

onthegrid007 gravatar image

Another issue if anyone knows how to remove the -z flag from where ever the cmake file is located or the proper flag that needs to be put in its place, please reply...

And here's the error...

 [ 47%] Linking CXX shared library ..\..\bin\libopencv_world343.dll
cd /d S:\SYSTEMS\CPP\OpenCV\mingw-64-build\modules\world && S:\TOOLCHAINS\OTHER\Cmake-3.12.2-win64-x64\bin\cmake.exe -E cmake_link_script CMakeFiles\opencv_world.dir\link.txt --verbose=1
S:\TOOLCHAINS\OTHER\Cmake-3.12.2-win64-x64\bin\cmake.exe -E remove -f CMakeFiles\opencv_world.dir/objects.a
S:\TOOLCHAINS\CPP\MinGW-64\bin\ar.exe cr CMakeFiles\opencv_world.dir/objects.a @CMakeFiles\opencv_world.dir\objects1.rsp
S:\TOOLCHAINS\CPP\MinGW-64\bin\g++.exe     -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wcast-align -Wstrict-aliasing=2 -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fstack-protector-strong -fPIC -DSTRSAFE_NO_DEPRECATE -O2 -DNDEBUG  -DNDEBUG -g1 -D_FORTIFY_SOURCE=2    -z noexecstack -z relro -z now   -shared -o ..\..\bin\libopencv_world343.dll -Wl,--out-implib,..\..\lib\libopencv_world343.dll.a -Wl,--major-image-version,3,--minor-image-version,4 -Wl,--whole-archive CMakeFiles\opencv_world.dir/objects.a -Wl,--no-whole-archive @CMakeFiles\opencv_world.dir\linklibs.rsp
S:/TOOLCHAINS/CPP/MinGW-64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: unrecognized option '-z'
S:/TOOLCHAINS/CPP/MinGW-64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: use the --help option for usage information
collect2.exe: error: ld returned 1 exit status
mingw32-make[3]: *** [modules\world\CMakeFiles\opencv_world.dir\build.make:6512: bin/libopencv_world343.dll] Error 1
mingw32-make[3]: Leaving directory 'S:/SYSTEMS/CPP/OpenCV/mingw-64-build'
mingw32-make[2]: *** [CMakeFiles\Makefile2:2794: modules/world/CMakeFiles/opencv_world.dir/all] Error 2
mingw32-make[2]: Leaving directory 'S:/SYSTEMS/CPP/OpenCV/mingw-64-build'
mingw32-make[1]: *** [Makefile:165: all] Error 2
mingw32-make[1]: Leaving directory 'S:/SYSTEMS/CPP/OpenCV/mingw-64-build'

Thanks again, -PF

edit retag flag offensive close merge delete


I looked a little closer into the the linking file CMake created and found these flags being tagged on the g++ execution. G++ has no reference to -z nor does ld which is not even being called here. I just might not understand the compilation process in its entirety yet and that's fine but I hope this may of be of some help to anyone who is able to find out what's wrong with the library compilation...

Thanks -PF

-z noexecstack -z relro -z now   -shared -o ..\..\bin\libopencv_world343.dll -Wl,--out-implib,..\..\lib\libopencv_world343.dll.a
onthegrid007 gravatar imageonthegrid007 ( 2018-09-22 12:52:38 -0500 )edit

indeed, mingw's ld does not have any -z options (the linux ld does have those !)

do you really NEED a single opencv_world lib ? try with cmake -DBUILD_opencv_world=OFF

(it's something with the packing of the different modules into a single lib)

berak gravatar imageberak ( 2018-09-24 06:44:56 -0500 )edit

I have compiled OpenCV 3.2.0 only once back in 2016 and it compiled using a 32bit flavor of MinGW to produce a folder containing a bunch of .dll files libopencv_world320d.dll being one of them, along with others like highgui and such... What I am getting from what your saying is that OpenCV_World is a DLL that 'world' is a dll containing EVERY module being compiled at that time?

This would be ideal to do now if possible, but if I need to, just turning that off, will that still allow all other modules including highgui DLL's and others to be compiled.

Because from my testing, OpenCV's core code header files and other items are stored in the world dll and if I attempt to run the executable on another computer not containing these dll's it does tell me which ones I need to also copy over..

onthegrid007 gravatar imageonthegrid007 ( 2018-09-24 10:18:14 -0500 )edit

that OpenCV_World is a DLL that 'world' is a dll containing EVERY module being compiled at that time?

correct. but this also seems to be the problem with mingw/cmake (unrelated to mingw, but the "world" approach also does not work, if you're using additional contrib modules).

can you try to switch it off, and see ?

a bunch of .dll files libopencv_world320d.dll being one of them, along with others like highgui

no, that's XOR. (you probably were seing results from different compile attempts, way back then)

berak gravatar imageberak ( 2018-09-24 10:22:48 -0500 )edit

I completely just made a new folder and ran through cmake-gui again making sure NOT to select build opencv_world and mingw32-make is running right now, I will inform of any future issues that may occur

onthegrid007 gravatar imageonthegrid007 ( 2018-09-24 10:55:26 -0500 )edit

@onthegrid007, can you find any solution to this problem? I'm struggling with this issue by using opencv4

saeid_masumi gravatar imagesaeid_masumi ( 2019-01-05 02:13:59 -0500 )edit

@saeid_masumi mingw's ld doesn't have a -z flag therefor you just need to not include the creation or linking of opencv_world lib and dll files. Basically just setting it to false it in cmake will solve this error.

[ 15%] Linking CXX shared library ....\bin\libopencv_cudev410.dll cd /d S:\SYSTEMS\CPP\OpenCV\build\x64\MinGW\modules\cudev && S:\TOOLCHAINS\OTHER\CMake-3.14.3-win64-x64\bin\cmake.exe -E cmake_link_script CMakeFiles\opencv_cudev.dir\link.txt --verbose=1


ld ... -z noexecstack -z relro -z now -shared -o ....\bin\libopencv_cudev410.dll


S:/TOOLCHAINS/CPP/MinGW-64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: unrecognized option '-z'

onthegrid007 gravatar imageonthegrid007 ( 2019-01-13 13:13:03 -0500 )edit