Problem with building OpenCV with Cmake in Windows

asked 2018-08-19 10:31:59 -0600

Aaron Kim gravatar image

updated 2018-08-21 00:20:10 -0600

System information (version)

  • OpenCV => 3.4.2 (clone the latest)
  • Operating System / Platform => Windows 10 64-Bit
  • Compiler => gcc 7.2.0 (minGW 5.3.0)

Configuring and generating with CMake works fine, but when I execute mingw32-make in the folder, it stops and shows the error message below.

[ 36%] Linking CXX shared library ..\..\bin\libopencv_core400.dll
CMakeFiles\opencv_core.dir/objects.a: member CMakeFiles\opencv_core.dir/objects.a(vs_version.rc.obj) in archive is not an object
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [modules\core\CMakeFiles\opencv_core.dir\build.make:1433: bin/libopencv_core400.dll] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:1694: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2

I can't find other issue which shows the same symptom, or at least a clue to solve this. I tried this tutorial either, but the same error occurs.

[+EDIT]

The line that causes error is below.

cd /d D:\opencv-build\modules\core && $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles\opencv_core.dir\link.txt --verbose=$(VERBOSE)

And I manually tried the command below in modules\core folder and it shows the same error.

cmake -E cmake_link_script CMakeFiles\opencv_core.dir\link.txt

[+EDIT2]

I successfully built it using OpenCV 3.2.0. I checked that 3.3.0 >= shows the error above.

edit retag flag offensive close merge delete

Comments

try again with:

cmake -DENABLE_PRECOMPILED_HEADERS=OFF

(and a clean build folder)

berak gravatar imageberak ( 2018-08-20 00:56:55 -0600 )edit

@berak Still shows the same error.

Aaron Kim gravatar imageAaron Kim ( 2018-08-20 04:33:01 -0600 )edit

no idea, what's wrong on your side, but i can build 3.4.2 successfully using mingw 7.2 here.

berak gravatar imageberak ( 2018-08-21 00:29:36 -0600 )edit

It seems that this guy had the same problem with me.. but ended up getting no solution. Maybe I just have to use 3.2.0 version

Aaron Kim gravatar imageAaron Kim ( 2018-08-21 00:34:43 -0600 )edit

no, you have to win the fight against cmake.

berak gravatar imageberak ( 2018-08-21 00:37:05 -0600 )edit

objects.a is the key. I searched it and found that someone said that toolchain can not recognize the format. But I think that it is not the problem related to my MinGW because I also tried building it using not only MinGW downloaded in Google, but also other MinGWs bundled with Qt, and TDM-GCC

Aaron Kim gravatar imageAaron Kim ( 2018-08-21 00:44:17 -0600 )edit

I have the exact same issue with exact same error message!! Any suggestion yet, pls?!!

BoboFuego gravatar imageBoboFuego ( 2018-10-09 11:25:48 -0600 )edit

No solution for this?

azagaya gravatar imageazagaya ( 2019-03-19 13:19:52 -0600 )edit

in cmake gui add entry OPENCV_VS_VERSIONINFO_SKIP = 1. It worked for me.

phuong gravatar imagephuong ( 2020-02-23 03:50:30 -0600 )edit