<div dir="ltr">Hello :)<br><br>I am one of the developers of OpenDungeons a FOSS RTS game inspired by Dungeon Keeper. I am trying to cross-compile our game on Ubuntu 12.04 for Windows (XP, Vista and 7), but I have run into some trouble.<br>
<br>I following these guides:<br><a href="http://www.cmake.org/Wiki/CMake_Cross_Compiling">http://www.cmake.org/Wiki/CMake_Cross_Compiling</a><br><a href="http://www.cmake.org/Wiki/CmakeMingw">http://www.cmake.org/Wiki/CmakeMingw</a><br>
<br>I use the following external libraries:<br><br>Ogre SDK 1.7.2 (MingW) <a href="https://sourceforge.net/projects/ogre/files/ogre/1.7/OgreSDK_mingw_v1-7-2.exe/download">https://sourceforge.net/projects/ogre/files/ogre/1.7/OgreSDK_mingw_v1-7-2.exe/download</a><br>
CEGUI SDK 0.7.5 (MingW) <a href="https://sourceforge.net/projects/crayzedsgui/files/CEGUI%20Mk-2/0.7.5/CEGUI-SDK-0.7.5-mingw.zip/download">https://sourceforge.net/projects/crayzedsgui/files/CEGUI%20Mk-2/0.7.5/CEGUI-SDK-0.7.5-mingw.zip/download</a><br>
SFML 1.6 (MingW) <a href="https://sourceforge.net/projects/sfml/files/sfml/1.6/SFML-1.6-dev-windows-mingw.zip/download">https://sourceforge.net/projects/sfml/files/sfml/1.6/SFML-1.6-dev-windows-mingw.zip/download</a><br><br>
and have made the following toolchain file (Toolchain.cmake):<br><br><div style="margin-left:40px"># this one is important<br>SET(CMAKE_SYSTEM_NAME Windows)<br>#this one not so much<br>SET(CMAKE_SYSTEM_VERSION 1)<br><br># specify the cross compiler<br>
SET(CMAKE_C_COMPILER /usr/bin/i686-w64-mingw32-gcc)<br>SET(CMAKE_CXX_COMPILER /usr/bin/i686-w64-mingw32-g++)<br>SET(CMAKE_RC_COMPILER /usr/bin/i686-w64-mingw32-windres)<br><br>SET(BOOST_ROOT ${CROSS_DIR}/OgreSDK_mingw_v1-7-2/boost)<br>
SET(CEGUIOGRE_LIBRARY ${CROSS_DIR}/OgreSDK_mingw_v1-7-2/lib/release)<br>SET(CEGUI_LIBRARY ${CROSS_DIR}/CEGUI/lib)<br>SET(CEGUI_INCLUDE_DIR ${CROSS_DIR}/CEGUI/cegui/include)<br>SET(OPENAL_LIBRARY ${CROSS_DIR}/SFML-1.6/lib)<br>
<br># where is the target environment<br>SET(CMAKE_FIND_ROOT_PATH ${CROSS_DIR}/OgreSDK_mingw_v1-7-2 ${CROSS_DIR}/SFML-1.6 ${CROSS_DIR}/CEGUI)<br><br># search for programs in the build host directories<br>SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)<br>
# for libraries and headers in the target directories<br>SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)<br>SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)<br></div><br>Which I use when I call cmake as follows:<br><br><div style="margin-left:40px">
export CROSS_DIR="`pwd`"<br>cd opendungeons*<br>cmake -DCROSS_DIR="$CROSS_DIR" -DCMAKE_TOOLCHAIN_FILE="$CROSS_DIR/Toolchain.cmake" .<br></div><br>Running cmake goes almost fine (I get the following warnings)<br>
<br><div style="margin-left:40px">ckr@ckr-laptop:~/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir$ ./CrossCompile.sh<br>...<br>-- Configuring done<br>WARNING: Target "OpenDungeons" requests linking to directory "/home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/SFML-1.6/lib". Targets may link only to libraries. CMake is dropping the item.<br>
WARNING: Target "OpenDungeons" requests linking to directory "/home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/CEGUI/lib". Targets may link only to libraries. CMake is dropping the item.<br>
WARNING: Target "OpenDungeons" requests linking to directory "/home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/OgreSDK_mingw_v1-7-2/lib/release". Targets may link only to libraries. CMake is dropping the item.<br>
WARNING: Target "OpenDungeons" requests linking to directory "/home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/SFML-1.6/lib". Targets may link only to libraries. CMake is dropping the item.<br>
WARNING: Target "OpenDungeons" requests linking to directory "/home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/CEGUI/lib". Targets may link only to libraries. CMake is dropping the item.<br>
WARNING: Target "OpenDungeons" requests linking to directory "/home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/OgreSDK_mingw_v1-7-2/lib/release". Targets may link only to libraries. CMake is dropping the item.<br>
-- Generating done<br>-- Build files have been written to: /home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/opendungeons-0.4.9<br></div><br>Which I am not sure are important or not (but that is not my question for now).<br>
<br>When I then compile our game with make I get the following error:<br><br><div style="margin-left:40px">ckr@ckr-laptop:~/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/opendungeons-0.4.9$ make<br>Scanning dependencies of target OpenDungeons<br>
[ 0%] Building CXX object CMakeFiles/OpenDungeons.dir/dependencies/angelscript/angelscript/source/as_atomic.cpp.obj<br>...<br>[ 44%] Building CXX object CMakeFiles/OpenDungeons.dir/source/ASWrapper.cpp.obj<br>In file included from /home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/OgreSDK_mingw_v1-7-2/boost_1_44/boost/thread/detail/thread_heap_alloc.hpp:15:0,<br>
from /home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/OgreSDK_mingw_v1-7-2/boost_1_44/boost/thread/tss.hpp:10,<br> from /home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/OgreSDK_mingw_v1-7-2/include/OGRE/Threading/OgreThreadHeadersBoost.h:29,<br>
from /home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/OgreSDK_mingw_v1-7-2/include/OGRE/Threading/OgreThreadHeaders.h:30,<br> from /home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/OgreSDK_mingw_v1-7-2/include/OGRE/OgreStdHeaders.h:110,<br>
from /home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/OgreSDK_mingw_v1-7-2/include/OGRE/OgrePrerequisites.h:315,<br> from /home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/OgreSDK_mingw_v1-7-2/include/OGRE/Ogre.h:31,<br>
from /home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/opendungeons-0.4.9/source/CameraManager.h:11,<br> from /home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/opendungeons-0.4.9/source/ASWrapper.cpp:27:<br>
/home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/OgreSDK_mingw_v1-7-2/boost_1_44/boost/thread/win32/thread_heap_alloc.hpp:59:40: warning: inline function ‘void* boost::detail::allocate_raw_heap_memory(unsigned int)’ declared as dllimport: attribute ignored [-Wattributes]<br>
/home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/OgreSDK_mingw_v1-7-2/boost_1_44/boost/thread/win32/thread_heap_alloc.hpp:69:39: warning: inline function ‘void boost::detail::free_raw_heap_memory(void*)’ declared as dllimport: attribute ignored [-Wattributes]<br>
In file included from /home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/opendungeons-0.4.9/source/ODFrameListener.h:16:0,<br> from /home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/opendungeons-0.4.9/source/ASWrapper.cpp:35:<br>
/home/ckr/Documents/OD SVN/mediaSource/ODLinuxBuildScripts/build_dir/opendungeons-0.4.9/dependencies/pthreads/include/pthread.h:307:8: error: redefinition of ‘struct timespec’<br>/usr/lib/gcc/i686-w64-mingw32/4.6/../../../../i686-w64-mingw32/include/sys/timeb.h:85:8: error: previous definition of ‘struct timespec’<br>
make[2]: *** [CMakeFiles/OpenDungeons.dir/source/ASWrapper.cpp.obj] Error 1<br>make[1]: *** [CMakeFiles/OpenDungeons.dir/all] Error 2<br>make: *** [all] Error 2<br></div><br>So the file pthread.h is imported twice, once from the external libraries that I want it to be imported from, but also from /usr/i686-w64-mingw32/include/sys/pthread.h which I do not want to to import it from. I have used the variable CMAKE_FIND_ROOT_PATH in my toolchain, and expected Cmake to only look here for external libraries, but it also looks in /usr/i686-w64-mingw32/include/sys. Am I doing something wrong in my toolchain file or what do I do fix this problem?<br>
<br>PS: I am pretty new to cmake, I am currently only doing the building and packaging of our game and not programming on it, so I do not deal with Cmake on a regular basis. This is my first time cross-compiling.<br><br>Thanks for any help :)<br>
Best regards<br>Casper :)<br></div>