-
Notifications
You must be signed in to change notification settings - Fork 41
CrossCompilation
This page describes process of cross-compiling win32 binaries of glosm using mingw32 on *nix system.
-
First, you need to install mingw32. In consists of multiple packages of which you'll need compiler, binutils, runtime and pthreads port. On FreeBSD, for example, you can get those by installing following ports:
- devel/mingw32-bin-msvcrt
- devel/mingw32-binutils
- devel/mingw32-gcc
- devel/mingw32-pthreads
-
Create a directory for cross-compilation environment. It's just convenient to hold all related files in one place, and you'll need it for cmake to search for required files. Lets's name it ${CROSSDIR}. Create ${CROSSDIR}/include ${CROSSDIR}/lib.
-
Get windows versions of required libraries
Extract library files from those (*.lib, *.dll) and place under ${CROSSDIR}/lib. Extract header files (*.h) as well and place them under ${CROSSDIR}/include
-
Create toolchain file for cmake. This is described on cmake wiki, and this is what I've used:
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_C_COMPILER mingw32-gcc)
SET(CMAKE_CXX_COMPILER mingw32-g++)
SET(CMAKE_C_FLAGS_RELEASE "-O2 -NDEBUG")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -NDEBUG")
SET(CMAKE_FIND_ROOT_PATH "/path/to/your/crossdir") # <- change this
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake /path/to/glosm/sources && make
Resulting .exe may be tested with wine. Place all required *.dll's (glosm-*.dll, glew, glut, expat etc.) into the same directory and run wine glosm-viewer.exe file.osm
- By default, cmake uses -O3 in Release build. mingw32-gcc 4.5.0 miscompiles viewer with -O3 so CMAKE_CXX_FLAGS_RELEASE should be tweaked as done in the toolchain file above.