2.1 build fails on MinGW: libvideoInput, SSE, examples (Bug #587)


Added by Charles Twardy over 14 years ago. Updated over 13 years ago.


Status:Done Start date:
Priority:High Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:build/install
Target version:-
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

Building OpenCV 2.1 on Windows with MinGW (in Eclipse)

There are several problems building OpenCV with
MinGW.
  • libvideoInput.a was built with gcc3.x and will not link under gcc4.x. Symptoms include "[bin/libhighgui210.dll] Error 1" and "undefined reference to @!+gxx_personality_sj0'" from videoInput.cpp. The fix involves replacing libvideoInput.a and editing src/highgui/CMakeLists.txt.
  • src/highgui/CMakeLists.txt may omit key libraries
  • On SVN but not stable:
    - BUILD_EXAMPLES fails to reference <stdint.h> or such.
    - SSE, SSE2 cause Internal Compiler Errors

This ticket updates Edoardo Bianco's post of 7 May 2010. Bianco reported the problem and described a solution using hints from ollydbg23 of the PyOpenCV project. See References, below. This post uses Eclipse, but the same fixes should apply to command-line MinGW builds, as it has the same errors.

Symptoms:

Somewhere after halfway through the build, it fails with errors like:

This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.
C:/OpenCV2.1.0/src/highgui/../../3rdparty/lib/libvideoInput.a(videoInput.o):videoInput.cpp:(.text+0xee): undefined reference to @+gxx_personality_sj0'
C:/OpenCV2.1.0/src/highgui/../../3rdparty/lib/libvideoInput.a(videoInput.o):videoInput.cpp:(.text+0x104): undefined reference to @_Unwind_SjLj_Register'
C:/OpenCV2.1.0/src/highgui/../../3rdparty/lib/libvideoInput.a(videoInput.o):videoInput.cpp:(.text+0x2a6): undefined reference to @_Unwind_SjLj_Unregister'

...

Creating library file: ../../lib/libhighgui210.dll.a
C:/OpenCV2.1.0/src/highgui/../../3rdparty/lib/libvideoInput.a(videoInput.o):videoInput.cpp:(.text+0x6d17): undefined reference to @_Unwind_SjLj_Register'
C:/OpenCV2.1.0/src/highgui/../../3rdparty/lib/libvideoInput.a(videoInput.o):videoInput.cpp:(.text+0x6e1e): undefined reference to @_Unwind_SjLj_Unregister'

...

maker2: * [bin/libhighgui210.dll] Error 1
maker1:
[src/highgui/CMakeFiles/highgui.dir/all] Error 2
maker1: Leaving directory @/c/OpenCV2.1.0-work/OpenCV_MinGW/release'
make: *
* [all] Error 2

Brief Solution

Presuming you already followed the Install Guide and have
OpenCV, Eclipse, CMake, MinGW, etc.
http://opencv.willowgarage.com/wiki/InstallGuide

A. Fix glitches in distribution before (re-)running CMake.
Assuming you downloaded to C:\OpenCV2.1:
- Replace libvideoInput.a.
  • cd c:\OpenCV2.1\3rdparry\lib
  • mv libvideoInput.a libvideoInput.a.orig (or such)
  • wget http://pyopencv.googlecode.com/files/libvideoInput.a
    (Or otherwise download and save that file.)
    - Add windows libraries (ole32 oleaut32 uuid) to src\highgui\CMakeLists.txt.
  • cd c:\OpenCV2.1\src\highgui
  • cp CMakeLists.txt CMakeLists.txt.orig
  • edit CMakeLists.txt
  • Replace "videoInput strmiids" with "videoInput strmiids ole32 oleaut32 uuid". [I didn't test this separately.]
B. (Re-)Run Cmake 2.8.1 to configure the project and create the Makefiles.
- Select appropriate root and build directories.
For example: "C:\OpenCV2.1" and "C:\OpenCV2.1\release".
- Click on the Configure button.
- Select "Eclipse CDT4 Unix Makefiles" as the Generator.
(For command-line MinGW builds, select MinGW or maybe MSYS.)
- Select options you like.
  • I enabled: BUILD_NEW_PYTHON_SUPPORT, BUILD_TESTS,
    INSTALL_C_EXAMPLES, INSTALL_PYTHON_EXAMPLES,
    OPENCV_BUILD_3RDPARTY_LIBS, USE_FAST_MATH, USE_O3,
    USE_OMIT_FRAME_POINTER
  • USE_SSE, USE_SSE2: yes for stable, no for SVN (as defaults).
    In the SVN release, they cause Internal Compiler
    Errors. See the PyOpenCV page for some discussion.
  • BUILD_EXAMPLES: yes for stable, no for SVN.
    Enabling in SVN caused some undefined references to standard
    items like "fprintf". Left off. Probably there is a simple fix.
  • Set CMAKE_BUILD_TYPE to "Release" [Or just leave blank.]
  • Check CMAKE_CONFIGURATION_TYPES is "Debug;Release"
  • Check that other values are sensible.
  • IPP, TBB: I don't have them, so they're off for me.
    - Click Configure again.
    - Click Generate

C. In Eclipse, (refresh and re-) build the project.
(For command-line builds, call the correct Make command.)

Detailed Solution:

Follows and summarizes the Install Guide
http://opencv.willowgarage.com/wiki/InstallGuide

0. Install OpenCV 2.1 into C:\OpenCV2.1
1. Install Eclipse
- Basic Eclipse
- Eclipse CDT 6.0 (Eclipse C++ plugin)
- Cmake Eclipse Editor
2. Install MinGW
- Edoardo's post refers to MinGW-5.1.6.exe + Update gcc_4.5, but the current mingw-get installer seems to work by default.
- Use default C:\MinGW directory!
- Add the following to the PATH:
  • C:\MinGW\bin;C:\MinGW\msys\1.0\bin;

3. Install Cmake 2.8.1

4. * Fix glitches *
Perform steps A and B from the Brief Solution, above.

5. Import the new project into Eclipse (or refresh it if there)
- Import project using Menu File->Import
- Select General->Existing projects into workspace:
- Browse to your build tree (e.g. "C:\OpenCV2.1\release" as above)
- Keep "Copy projects into workspace" unchecked.
- You get a fully functional eclipse project!
(See http://www.cmake.org/Wiki/Eclipse_CDT4_Generator)

6. Build the project
- Deselect Project -> Build Automatically (for now at least)
- Right-click on the project and "Refresh" (or press F5)
- Project -> Build Project
Or right-click the project and select "Build Project"
- Wait and watch. Warnings are expected, but it should not have errors.

7. Optional: (also) compile in debug mode instead of release mode
See "Changing Build Configuration to Release",
http://wiki.wxwidgets.org/Eclipse,_CDT_&_MingW_&_MSYS_Setup_Guide#Changing_the_Build_Configuration

8. Test.
- Try to run programs in your release\bin directory.
-> From DOS or Windows, not from cygwin!
- As described at http://opencv.willowgarage.com/wiki/InstallGuide

References

Edoardo Bianco's Post:
#71043: http://tech.groups.yahoo.com/group/OpenCV/message/71043

Documentation for these changes is available here:
http://code.google.com/p/pyopencv/wiki/Installation_OpenCV
http://code.google.com/p/pyopencv/
http://sourceforge.net/tracker/index.php?func=detail&aid=2939647&group_id=22870&atid=376677


Associated revisions

Revision fba0e6fc
Added by Andrey Kamaev about 12 years ago

Merge pull request #587 from bitwangyaoyao:2.4_fixHog

History

Updated by Vadim Pisarevsky over 13 years ago

Now videoInput is put inside highgui and should build fine with recent versions of MinGW (as well as the samples etc.) SSE optimization is also behaves well (OpenCV v2.3 or later)

However, it's recommended to use "-O2" optimization. With "-O3" MinGW is known to produce incorrect code. GCC 4.6.1 is also not recommended yet, may be further versions in 4.6.x branch will be better.

  • (deleted custom field) set to fixed

Also available in: Atom PDF