Difference between revisions of "Setup the build environment"

From RobotinoWiki
(Building with Visual Studio 2010 for Windows 32 Bit)
Line 1: Line 1:
 +
==Using binary packages==
 +
Get the openrobotino1 binary packages for [http://doc.openrobotino.org/download/OpenRobotinoAPI/1/current_win32_vc90.php Windows] or [http://doc.openrobotino.org/download/packages/ Debian/Linux]. Linux users could also edit /etc/apt/sources.list and add
 +
<pre>deb http://doc.openrobotino.org/download/packages/ ./</pre>
 +
 
==Building from source==
 
==Building from source==
 
===The recommended way===
 
===The recommended way===

Revision as of 11:33, 3 January 2011

Using binary packages

Get the openrobotino1 binary packages for Windows or Debian/Linux. Linux users could also edit /etc/apt/sources.list and add

deb http://doc.openrobotino.org/download/packages/ ./

Building from source

The recommended way

Download the external depencies package. (REC internal \\fileserver\openrobotino_external*)

Unpack the 7z archive to a local harddisk. On Linux

sudo apt-get install p7zip
7zr x openrobotino_external_20101230.7z
find external -wholename "*/bin/*" -exec chmod +x {} \;

Set the environment variable OPENROBOTINO_EXTERNAL_DIR to the full path of the just unpacked external folder.

Get the sources via SVN from http://svn.openrobotino.org/trunk

Use cmake to configure the openrobotino1 folder.


Building with Visual Studio 2010 for Windows 32 Bit

First of all Visual Studio 2010 is not supported (by now). There is no guarantee that this instruction will work. Furthermore there is no guarantee for a successful compilation with the built API nor no problems by running programs compiled with it.

english instruction

After downloading trunk and extracting external into it there are some modification needed. At first boost an qt libraries have to build with Visual Studio 2010. Then the support for vc100 and those libraries some cmake files have to be manipulated. Some project files have to be created, too. At least six of the generated project files must be changed.

boost 1.41

Most of the needed things are named in HOW_TO_BUILD.txt under the boost directory of the external:
Download and extract boost 1.41.0 and download the binaries for boost jam and extract the exe file in the boost source folder. Now open a Visual Studio Command Prompt and move to the boost source. Now compile boost with the following command. The command is longer than in the text file:

bjam release debug link=static threading=multi --with-thread --with-date_time --with-filesystem \
     --with-regex --with-system --with-wave --with-math --with-serialization --with-test \
     --with-signals --with-graph --with-iostreams --with-program_options stage

After succeed there should be 84 files in the subfolder "stage/lib". You need the files with "1_41" in the name. Copy these 42 libraries into "external\boost\1_41\lib\win32" of the OpenrobotinoAPI.

qt 4.7.1

Download qt source from http://get.qt.nokia.com/qt/source/ and extract it. The file qt-everywhere-opensource-src-4.7.1.zip is needed. Open a Visual Studio Command Prompt and change into the qt source directory. Now qt can be compiled for debug and release. It will compile for hours:

configure -debug-and-release -static -opensource -platform win32-msvc2010 -no-qt3support \
          -qtnamespace openrobotinoqt -no-gif -no-libmng -no-libtiff -no-libjpeg -no-dsp -no-vcproj \
          -no-phonon -no-webkit -no-scripttools
nmake

After finishing the needed files are in the bin and lib subfolder. They have to be copied to "external\qt\4_7_1_static_openrobotinoqt\bin\win32\vc100" or "external\qt\4_7_1_static_openrobotinoqt\lib\win32\vc100". The directories "vc100" have to be created. You need "moc.exe" and "rcc.exe" from bin and the following files of the lib-folder:

QtCore.lib
QtGui.lib
qtmain.lib
QtNetwork.lib
QtSvg.lib
QtXml.lib

QtCored.lib
QtGuid.lib
qtmaind.lib
QtNetworkd.lib
QtSvgd.lib
QtXmld.lib

cmake configuration file

There are four files to change to enable Visual Studio 2010 support. They resists in the subfolder "tools\cmake" of the API. In the following parts of the files "+" means to add the Line an nothing that the file is not changed.

architecture.cmake:

 	#check for Visual Studio 2008
 	ELSEIF( MSVC90 )
 		SET( COMPILER_NAME vc90 )
 	
+	#check for Visual Studio 2010
+	ELSEIF( MSVC10 )
+		SET( COMPILER_NAME vc100 )
+	
 	ELSE( MSVC71 )

FindMyBoost.cmake:

 	IF( MSVC90 )
 		SET( BOOST_COMPILER_NAME vc90 )
+	#check for Visual Studio 2010
+	ELSEIF( MSVC10 )
+		SET( BOOST_COMPILER_NAME vc100 )
 	#check for Visual Studio 2005

FindMyQt4.cmake:

 	#check for Visual Studio 2008
 	ELSEIF( MSVC90 )
 		SET( QT_COMPILER_NAME vc90 )
 		SET( QT_MKSPECS_DIR ${QT_PATH}/mkspecs/win32-msvc2008 )
+		
+	#check for Visual Studio 2010, 
+	#attention: QT 4.5.1 has no mkspecs/win32-msvc2010, but 4.7.1, so copy it
+	ELSEIF( MSVC10 )
+		SET( QT_COMPILER_NAME vc100 )
+		SET( QT_MKSPECS_DIR ${QT_PATH}/mkspecs/win32-msvc2010 )
 		
 	ELSE( MSVC71 )

FindMyQt4_static_openrobotinoqt.cmake:

 	#check for Visual Studio 2008
 	ELSEIF( MSVC90 )
 		SET( QT_COMPILER_NAME vc90 )
 		SET( QT_MKSPECS_DIR ${QT_PATH}/mkspecs/win32-msvc2008 )
+		
+	#check for Visual Studio 2010
+	ELSEIF( MSVC10 )
+		SET( QT_COMPILER_NAME vc100 )
+		SET( QT_MKSPECS_DIR ${QT_PATH}/mkspecs/win32-msvc2010 )
 		
 	ELSE( MSVC71 )

Warning: I have problems with the current Version of the API (date 01.01.2011) with some cmake files. OPENROBOTINO_EXTERNAL_DIR is not set. So I used the following workaround which goes a step back to a previous version: tools/find_library.cmake:

 	
 	SET(
 		LIB_SEARCH_PATH
-		$ENV{OPENROBOTINO_EXTERNAL_DIR}/${CURRENT_LIB}
+		${REC_MAIN_DIR}/external/${CURRENT_LIB}
 	)
 

openrobotino1/tools/iomon/CMakeLists.txt:


-SET( EXTERNAL_DIR $ENV{OPENROBOTINO_EXTERNAL_DIR} )
+SET(  EXTERNAL_DIR ${REC_MAIN_DIR}/external )
STRING( REPLACE "\\" "/" EXTERNAL_DIR "${EXTERNAL_DIR}" )

Jetzt hat cmake bei mir keine Fehler mehr gemeldet.


example project files

To make cmake able to create the exemple projects some project files and cmake files have to be modificated.
First of all the project files for Visual Studio 2010 have to be created. So copy the vc90.vcproj file to vc100.vcproj. Then open these file with Visual Studio 2010 an convert it. There are more files created than needed. Thus the following files can be deleted:

_UpgradeReport_Files
UpgradeLog.XML
vs100.sdf
vs100.vcproj
vs100.vcxproj.user

The two files "vs100.vcxproj" and "vs100.vcxproj.filters" will remain.
This has to be done in the folders "openrobotino1\examples\c++" and "openrobotino1\examples\c".

Then the CMakeLists.txt in "openrobotino1\examples\c++" and "openrobotino1\examples\c" should be modificate:

	ELSEIF( MSVC90 )
		CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/vs90.vcproj ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcproj @ONLY )
+	ELSEIF( MSVC10 )
+		CONFIGURE_FILE( 
+			${CMAKE_CURRENT_SOURCE_DIR}/vs100.vcxproj 
+			${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcxproj 
+			@ONLY 
+		)
+		CONFIGURE_FILE( 
+			${CMAKE_CURRENT_SOURCE_DIR}/vs100.vcxproj.filters 
+			${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcxproj.filters 
+			@ONLY 
+		)
	ENDIF( MSVC71 )

and

  
	IF( WIN32 )
-    INSTALL(
-      FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcproj
-      DESTINATION ${OPENROBOTINO_C_EXAMPLES_INSTALL_DIR}/${NAME}
-    )
+		IF( MSVC10 )
+			INSTALL(
+				FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcxproj
+				DESTINATION ${OPENROBOTINO_C_EXAMPLES_INSTALL_DIR}/${NAME}
+			)
+			INSTALL(
+				FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcxproj.filters
+				DESTINATION ${OPENROBOTINO_C_EXAMPLES_INSTALL_DIR}/${NAME}
+			)
+		ELSE( MSVC10 )
+			INSTALL(
+				FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcproj
+				DESTINATION ${OPENROBOTINO_C_EXAMPLES_INSTALL_DIR}/${NAME}
+			)
+		ENDIF( MSVC10 )
  ENDIF( WIN32 )

building OpenrobotinoAPI

Now cmake can be used. After downloading and installing or extracting the newest version from http://www.cmake.org/cmake/resources/software.html. "cmake-gui.exe" has to be called from the bin directory of cmake. Fill in the path to "openrobotino1" of the API source into "Where is the source code" and your favorite folder in "Where to build the binaries". Now "configure", "configure" and "generate". Use "Visual Studio 10" as compiler. Then open a project file of your favorite folder. The properties of the six projects "armd", "arm_debugger", "iomon", "example_qtclient", "rec_robotino_server" and "rec_robotino_comd" have to be changed. You need in the debug version of the solution the debug versions the qt libraries. So add the "d" to the end of all the qt file names under "Configuration Properties", "Linker", "Input", "Additional Dependencies" in the project properties. It is possible that the files are widespread in "Additional Dependencies".
To build the API set "INSTALL" as start project and build it in debug or release mode. The result, the builded API, resists in the subfolder "install".


german instruction

Nachdem das aktuelle "trunk" heruntergeladen wurde und "external" dort extrahiert wurde fehlen noch einige Änderungen. Boost und QT müssen mit Visual Studio 2010 kompiliert werden. Ferner sind einige cmake-Dateien anzupassen.

boost 1.41

Es reicht die Anleitung von HOW_TO_BUILD.txt des boost-Ordners zu befolgen. Dies umfasst:
Nach dem Herunterladen von boost 1.41.0 wird auch boost jam als binary heruntergeladen und in den boost-Ordner entpackt. Nun kann es gebaut werden. Dabei werden allerdings mehr Parameter angegeben, als in der txt-Datei stehen.

bjam release debug link=static threading=multi --with-thread --with-date_time --with-filesystem \
     --with-regex --with-system --with-wave --with-math --with-serialization --with-test \
     --with-signals --with-graph --with-iostreams --with-program_options stage

Danach müsste es in dem Unterordner "stage" ein lib-Ordner existiert. Dort müssten nun 84 Dateien liegen. Alle Dateien die ein "1_41" im Namen tragen - 42 an der Zahl - sind nun in den Ordner "external\boost\1_41\lib\win32" der OpenrobotinoAPI zu kopieren.

qt 4.7.1

Zuerst gilt es den Quelltext von qt auf der Webseite herunter (Datei qt-everywhere-opensource-src-4.7.1.zip) zu laden und zu entpacken. Im Anschluss wird die Eingabeaufforderung von Visual Studio 2010 gestartet und in das Verzeichnis von qt gewechselt. Nun muss qt vor dem bauen konfiguriert werden. Das Bauen selber wird je nach Rechenleistung Stunden dauern. Es muss in release und debug gebaut werden.

configure -debug-and-release -static -opensource -platform win32-msvc2010 -no-qt3support \
          -qtnamespace openrobotinoqt -no-gif -no-libmng -no-libtiff -no-libjpeg -no-dsp -no-vcproj \
          -no-phonon -no-webkit -no-scripttools
nmake

Nachdem nun alles erstellt wurde, finden sich die benötigten Dateien in den Ordnern bin und lib. Diese sind nach "external\qt\4_7_1_static_openrobotinoqt\bin\win32\vc100" bzw. "external\qt\4_7_1_static_openrobotinoqt\lib\win32\vc100" kopiert werden. "vc100" muss dabei jeweils extra angelegt werden. Aus dem bin-Ordner werden die Dateien "moc.exe" und "rcc.exe" benötigt. Vom lib-Ordner sind folgende Dateien zu kopieren:

QtCore.lib
QtGui.lib
qtmain.lib
QtNetwork.lib
QtSvg.lib
QtXml.lib

QtCored.lib
QtGuid.lib
qtmaind.lib
QtNetworkd.lib
QtSvgd.lib
QtXmld.lib

CMake-Konfigurationsdateien

Zwar sind nun alle Daten vorhanden, jedoch wird CMake vermutlich noch einige Probleme haben, da die vorhandenen Dateien kein Visual Studio 2010 vorsehen. Deshalb gilt es diese zu verändern. Diese sind unter "tools\cmake" zu finden. "+" bedeutet dabei "Zeile muss hinzu gefügt werden", "-" "Zeile muss entfernt werden" und " " bedeutet "Zeile bleibt so".

architecture.cmake:

 	#check for Visual Studio 2008
 	ELSEIF( MSVC90 )
 		SET( COMPILER_NAME vc90 )
 	
+	#check for Visual Studio 2010
+	ELSEIF( MSVC10 )
+		SET( COMPILER_NAME vc100 )
+	
 	ELSE( MSVC71 )

FindMyBoost.cmake:

 	IF( MSVC90 )
 		SET( BOOST_COMPILER_NAME vc90 )
+	#check for Visual Studio 2010
+	ELSEIF( MSVC10 )
+		SET( BOOST_COMPILER_NAME vc100 )
 	#check for Visual Studio 2005

FindMyQt4.cmake:

 	#check for Visual Studio 2008
 	ELSEIF( MSVC90 )
 		SET( QT_COMPILER_NAME vc90 )
 		SET( QT_MKSPECS_DIR ${QT_PATH}/mkspecs/win32-msvc2008 )
+		
+	#check for Visual Studio 2010, 
+	#attention: QT 4.5.1 has no mkspecs/win32-msvc2010, but 4.7.1, so copy it
+	ELSEIF( MSVC10 )
+		SET( QT_COMPILER_NAME vc100 )
+		SET( QT_MKSPECS_DIR ${QT_PATH}/mkspecs/win32-msvc2010 )
 		
 	ELSE( MSVC71 )

FindMyQt4_static_openrobotinoqt.cmake:

 	#check for Visual Studio 2008
 	ELSEIF( MSVC90 )
 		SET( QT_COMPILER_NAME vc90 )
 		SET( QT_MKSPECS_DIR ${QT_PATH}/mkspecs/win32-msvc2008 )
+		
+	#check for Visual Studio 2010
+	ELSEIF( MSVC10 )
+		SET( QT_COMPILER_NAME vc100 )
+		SET( QT_MKSPECS_DIR ${QT_PATH}/mkspecs/win32-msvc2010 )
 		
 	ELSE( MSVC71 )

Anmerkung: Bei meiner aktuellen Version (Stand 01.01.2011) gibt es einen Fehler in den cmake-Dateien. OPENROBOTINO_EXTERNAL_DIR ist nicht gesetzt. Deshalb habe ich als "workaround" folgende Änderung vorgenommen. Dabei handelt es sich teilweise um eine frühere Version: tools/find_library.cmake:

 	
 	SET(
 		LIB_SEARCH_PATH
-		$ENV{OPENROBOTINO_EXTERNAL_DIR}/${CURRENT_LIB}
+		${REC_MAIN_DIR}/external/${CURRENT_LIB}
 	)
 

openrobotino1/tools/iomon/CMakeLists.txt:


-SET( EXTERNAL_DIR $ENV{OPENROBOTINO_EXTERNAL_DIR} )
+SET(  EXTERNAL_DIR ${REC_MAIN_DIR}/external )
STRING( REPLACE "\\" "/" EXTERNAL_DIR "${EXTERNAL_DIR}" )

Jetzt hat cmake bei mir keine Fehler mehr gemeldet.


Beispielprojekte

Damit die Beispiele erstellt werden können, müssen Projektdateien und CMake-Dateien angepasst werden.
Für die Anpassung der Projektdateien wird am Besten die vc90.vcproj Datei nach vc100.vcproj kopiert. Im Anschluss wird sie mit Visual Studio 2010 geöffnet und konvertiert. Die folgenden Dateien und Ordner werden dann nicht mehr benötigt und können gelöscht werden:

_UpgradeReport_Files
UpgradeLog.XML
vs100.sdf
vs100.vcproj
vs100.vcxproj.user

Es verbleiben die beiden Dateien "vs100.vcxproj" und "vs100.vcxproj.filters" die benötigt werden.
Dies muss in "openrobotino1\examples\c++" und "openrobotino1\examples\c" gemacht werden.

Dazu sind die CMakeLists.txt Dateien in "openrobotino1\examples\c++" und "openrobotino1\examples\c" anzupassen:

	ELSEIF( MSVC90 )
		CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/vs90.vcproj ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcproj @ONLY )
+	ELSEIF( MSVC10 )
+		CONFIGURE_FILE( 
+			${CMAKE_CURRENT_SOURCE_DIR}/vs100.vcxproj 
+			${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcxproj 
+			@ONLY 
+		)
+		CONFIGURE_FILE( 
+			${CMAKE_CURRENT_SOURCE_DIR}/vs100.vcxproj.filters 
+			${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcxproj.filters 
+			@ONLY 
+		)
	ENDIF( MSVC71 )

und

  
	IF( WIN32 )
-    INSTALL(
-      FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcproj
-      DESTINATION ${OPENROBOTINO_C_EXAMPLES_INSTALL_DIR}/${NAME}
-    )
+		IF( MSVC10 )
+			INSTALL(
+				FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcxproj
+				DESTINATION ${OPENROBOTINO_C_EXAMPLES_INSTALL_DIR}/${NAME}
+			)
+			INSTALL(
+				FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcxproj.filters
+				DESTINATION ${OPENROBOTINO_C_EXAMPLES_INSTALL_DIR}/${NAME}
+			)
+		ELSE( MSVC10 )
+			INSTALL(
+				FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.vcproj
+				DESTINATION ${OPENROBOTINO_C_EXAMPLES_INSTALL_DIR}/${NAME}
+			)
+		ENDIF( MSVC10 )
  ENDIF( WIN32 )


OpenrobotinoAPI bauen

Als erstes wird die aktuelle CMake-Version benötigt. Diese kann unter http://www.cmake.org/cmake/resources/software.html herunter geladen werden. Nach dem Entpacken oder installieren wird "cmake-gui.exe" ausgeführt. Als "Where is the source code" wird der Pfad zu "openrobotino1" incl. gewählt. Als Zielort ("Where to build the binaries") wird der Wunschordner gewählt. Es folgt "configure", "configure" und "generate". Bei Nachfrage wird "Visual Studio 10" gewählt. Die direkte Arbeit mit CMake ist damit beendet.
Nun wird ein Visual Studio Projekt in dem Zielordner geöffnet, wodurch die komplette Solution-Datei geöffnet wird. Sechs Projekte gilt es an zu passen. Diese sind "armd", "arm_debugger", "iomon", "example_qtclient", "rec_robotino_server" und "rec_robotino_comd". Bei ihnen müssen in der Debug-Version auch die Debug-QT-Bibliotheken verwendet werden. Es gilt also in den Projekteigenschaften unter "Konfigurationseigenschaften", "Linker", "Eingabe", "Zusätzliche Abhängigkeiten" ein "d" am Ende des Dateinamens vor der Endung ein zu tragen. Es kann passieren, dass die Lib-Dateien innerhalb von "Zusätzliche Abhängigkeiten" verstreut angeordnet sind. Es müssen aber alle auf die Debug-Versionen umgestellt werden. Nun kann "INSTALL" als Startprojekt gewählt und je nach Wunsch in Release oder Debug gebaut werden. Die gebaute API findet sich dann im Ordner "install" unter dem Projektordner.