dimanche 31 août 2014

Cross-Compiling C++ OpenCV project on Ubuntu 12.04 for Windows 7


Vote count:

0




I am new to cross compiling and have a problem with compiling a C++ project using OpenCV 2.4.9 on Ubuntu 12.04 for Windows 7. Unfortunately I did not find an appropriate solution here or elsewhere on the web.


Here are some more details:



  • I use cmake to create the makefiles

  • Compilation works fine for Ubuntu

  • I installed mingw32

  • I had to add some symbolic links to /usr/local/include/opencv2/ in the /usr/i586-mingw32msvc/include/ folder to resolve dependencies.


My Toolchain-mingw32.cmake looks like this:



SET(CMAKE_SYSTEM_NAME Windows)

SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres)
SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)

SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc)

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)


My CMakeLists.txt looks like this:



cmake_minimum_required(VERSION 2.8.3)
project(process)

find_package(OpenCV REQUIRED)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()

set(CMAKE_BUILD_TYPE Release)

add_executable(process process.cpp <more .cpp-files>)

target_link_libraries(process ${OpenCV_LIBS} ${OpenMP_LIBS})


When I run cmake in the build folder (build/x86/windows/release)



cmake -DCMAKE_TOOLCHAIN_FILE=../../../../src/Toolchain-mingw32.cmake
../../../../src/


I get the following result:



-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/i586-mingw32msvc-gcc
-- Check for working C compiler: /usr/bin/i586-mingw32msvc-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/i586-mingw32msvc-g++
-- Check for working CXX compiler: /usr/bin/i586-mingw32msvc-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: build/x86/windows/release


Then I make and get the following error:



make

Scanning dependencies of target process
[ 6%] Building CXX object CMakeFiles/http://ift.tt/1r1igHs
...
[100%] Building CXX object CMakeFiles/http://ift.tt/1nifFnP
make[2]: *** No rule to make target `opencv_videostab-NOTFOUND', needed by `process.exe'. Stop.
make[1]: *** [CMakeFiles/process.dir/all] Error 2
make: *** [all] Error 2


Cross compiling without special dependencies works. Any help is appreciated!



asked 44 secs ago







Cross-Compiling C++ OpenCV project on Ubuntu 12.04 for Windows 7

Aucun commentaire:

Enregistrer un commentaire