Ask Your Question

Revision history [back]

Problem linking shared library libopencv_core340.dll with MinGW 64

System information (version)

  • OpenCV => 3.4
  • Operating System / Platform => Windows 10 64 Bit
  • Compiler => GCC/G++ 4.9.3 (MinGW 64)

Detailed description

I receive the following linking error when trying to compile OpenCV 3.4 on Windows 10 with MinGW 64.

[ 41%] Linking CXX shared library ../../bin/libopencv_core340.dll
C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `CMakeFiles/opencv_core.dir/objects.a(vs_version.rc.obj)' is incompatible with i386:x86-64 output 
collect2.exe: error: ld returned 1 exit status 
make[2]: *** [bin/libopencv_core340.dll] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2 
make: *** [all] Error 2

Steps to reproduce

Cmake command:

cmake -G "Unix Makefiles" -DCMAKE_C_COMPILER=C:/Rtools/mingw_64/bin/gcc.exe -DCMAKE_CXX_COMPILER=C:/Rtools/mingw_64/bin/g++.exe -DENABLE_PRECOMPILED_HEADERS=OFF -DBUILD_opencv_world=OFF -DBUILD_opencv_contrib_world=OFF -DBUILD_matlab=OFF -DPYTHON_EXECUTABLE=OFF -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=../../../opencv/ ../

Cmake output:

-- General configuration for OpenCV 3.4.0 =====================================
--   Version control:               unknown
--
--   Platform:
--  Timestamp:                  2018-01-10T17:12:14Z
--  Host:                       Windows 10.0.16299 AMD64
--  CMake:                      3.7.2
--  CMake generator:            Unix Makefiles
--  CMake build tool:           C:/Rtools/bin/make.exe
--  Configuration:              RELEASE
--
--   CPU/HW features:
--  Baseline:                   SSE SSE2 SSE3
--      requested:              SSE3
--  Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2
--      requested:              SSE4_1 SSE4_2 AVX FP16 AVX2
--      SSE4_1 (3 files):       + SSSE3 SSE4_1
--      SSE4_2 (1 files):       + SSSE3 SSE4_1 POPCNT SSE4_2
--      FP16 (2 files):         + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--      AVX (5 files):          + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--      AVX2 (9 files):         + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--
--   C/C++:
--  Built as dynamic libs?:     YES
--  C++ Compiler:               C:/Rtools/mingw_64/bin/g++.exe  (ver 4.9.3)
--  C++ flags (Release):        -fsigned-char -mstackrealign -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--  C++ flags (Debug):          -fsigned-char -mstackrealign -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--  C Compiler:                 C:/Rtools/mingw_64/bin/gcc.exe
--  C flags (Release):          -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
--  C flags (Debug):            -fsigned-char -mstackrealign -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
--  Linker flags (Release):     -Wl,--gc-sections
--  Linker flags (Debug):       -Wl,--gc-sections
--  ccache:                     NO
--  Precompiled headers:        NO
--  Extra dependencies:
--  3rdparty dependencies:
--
--   OpenCV modules:
--  To be built:                calib3d core dnn features2d flann highgui imgcodecs imgproc ml objdetect photo python_bindings_generator shape stitching superres ts video videoio videostab
--  Disabled:                   js world
--  Disabled by dependency:     -
--  Unavailable:                cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 python3 viz
--  Applications:               tests perf_tests apps
--  Documentation:              NO
--  Non-free algorithms:        NO
--
--   Windows RT support:            NO
--
--   GUI:
--  Win32 UI:                   YES
--  VTK support:                NO
--
--   Media I/O:
--  ZLib:                       build (ver 1.2.11)
--  JPEG:                       build (ver 90)
--  WEBP:                       build (ver encoder: 0x020e)
--  PNG:                        build (ver 1.6.34)
--  TIFF:                       build (ver 42 - 4.0.9)
--  JPEG 2000:                  build (ver 1.900.1)
--  OpenEXR:                    build (ver 1.7.1)
--
--   Video I/O:
--  Video for Windows:          YES
--  DC1394:                     NO
--  FFMPEG:                     YES (prebuilt binaries)
--      avcodec:                YES (ver 57.89.100)
--      avformat:               YES (ver 57.71.100)
--      avutil:                 YES (ver 55.58.100)
--      swscale:                YES (ver 4.6.100)
--      avresample:             YES (ver 3.5.0)
--  GStreamer:                  NO
--  DirectShow:                 YES
--
--   Parallel framework:            none
--
--   Trace:                         YES (built-in)
--
--   Other third-party libraries:
--  Lapack:                     NO
--  Eigen:                      NO
--  Custom HAL:                 NO
--
--   NVIDIA CUDA:                   NO
--
--   OpenCL:                        YES (no extra features)
--  Include path:               C:/Users/Simon/Downloads/opencv-3.4.0/3rdparty/include/opencl/1.2
--  Link libraries:             Dynamic load
--
--   Python (for build):            NO
--
--   Java:
--  ant:                        NO
--  JNI:                        NO
--  Java wrappers:              NO
--  Java tests:                 NO
--
--   Matlab:                        NO
--
--   Install to:                    C:/Users/Simon/opencv
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Simon/Downloads/opencv-3.4.0/build64