查看: 13834|回复: 7

FlightGear2.8.0 + OSG3.0.1 VS2010编译指南

[复制链接]
发表于 2014-2-25 19:13:33 | 显示全部楼层 |阅读模式
Jinchengde(jinchengde@gmail.com)
首先需要下载CMake
下载地址http://www.cmake.org/cmake/resources/software.html
下载Windows版本安装完成后待用,CMake设置编译器为VS10 Native即可
在C盘创建flightgear和OpenSceneGraph目录
如果想跳过OSG的编译,可以直接从http://openscenegraph.alphapixel.com/osg/downloads/free-openscenegraph-binary-downloads下载已经编译好的二进制代码,解压至C:\FlightGear\install\msvc100\OpenSceneGraph
关于编译工具,如果只需要编译FG的话,那么VS2010学习版即可,但是编译OSG的时候需要用到MFC的头文件,所以需要VS2010专业版以上。
OSG3.0.1编译
OSG3.0.1的源码可以从http://www.osgchina.org/projects/osgcn/wikicn/Downloads.php下载
OSG编译需要的第三方库可以从http://members.iinet.net.au/~bchrist/下载
OSG的数据文件可以从http://www.openscenegraph.org/downloads/stable_releases/OpenSceneGraph-3.0/data/OpenSceneGraph-Data-3.0.0.zip下载
将OSG的源码,OSG的第三方库和数据文件解压到C:\OpenSceneGraph,创建OpenSceneGraph-Build待用,如下:
打开cmake-gui,设置如下:
勾选Advanced后,
Where is the source code设置为C:/OpenSceneGraph/OpenSceneGraph-3.0.1
Where to build the binaries设置为C:/OpenSceneGraph/OpenSceneGraph-Build
ACTUAL_3RDPARTY_DIR 设置为C:/OpenSceneGraph/3rdParty/x86
CMAKE_INSTALL_PREFIX设置为C:/FlightGear/install/msvc100/OpenSceneGraph
勾选BUILD_MFC_EXAMPLE,BUILD_OSG_EXAMPLES
点击Configure
直至Generate可用,点击Generate生成工程文件
打开VS2010,选择 文件-打开-项目/解决方案,打开位于C:\OpenSceneGraph\OpenSceneGraph-Build下面的工程文件OpenSceneGraph.sln
项目打开后如下所示
将解决方案配置修改为Release
按F7生成解决方案,编译时间大概需要2个小时
编译完成后在解决方案资源管理器中找到INSTALL项目,右击选择生成
相关文件将自动被拷贝到C:/FlightGear/install/msvc100/OpenSceneGraph目录下
FlightGear 2.8.0编译
FlightGear的源代码可以从http://www.flightgear.org/download/source-code/下载
需要下载FligtGear,SimGear和Base Package三个部分
可以从ftp://ftp.ihg.uni-duisburg.de/FlightGear/Win32/MSVC/下载第三方库,包括3rdParty和Boost,目前最新的为fgfs-win32-VS100-3rdParty+OSG-20120411.zip和boost_1_44_0-libs-vc100.zip
将下载的文件放到C:\FlightGear并解压,同时创建flightgear-build和simgear-build空文件夹,目录设置如下:
${MSVC_3RDPARTY_ROOT} /
3rdParty /
( includes boost, plib, fltk, zlib, libpng, libjpeg, libtiff, freetype, libsvn, gdal, ... )
bin /
include /
lib /
boost_1_44_0 /
(included in the 3rdParty package linked above)
boost /
install /
msvc100 /
( for VS2010 32 bits, or msvc90, msvc90-64 or msvc100-64 for VS2008 32, VS2008 64 and VS2010 64 )
OpenSceneGraph /
( OSG CMake install )
bin /
include /
lib /
SimGear /
(create this empty for now, subfolders will be created by build process)
include /
lib /
FlightGear /
(create this empty for now)
include /
lib /
目录设置如下:
SimGear编译
打开cmake-gui
Where is the source code设置为C:/FlightGear/simgear-2.8.0
Where to build the binaries设置为C:/FlightGear/simgear-build
MSVC_3RDPARTY_ROOT设置为C:/FlightGear
CMAKE_INSTALL_PREFIX设置为C:/FlightGear/install/msvc100/SimGear
点击Configure直至Generate可用,点击Generate生成工程文件
打开位于C:\FlightGear\simgear-build的工程文件SimGear.sln
设置解决方案配置为Release
按F7生成解决方案,编译完成后,找到INSTALL工程,右击选择生成
相关库文件被自动拷贝到C:\FlightGear\install\msvc100\SimGear文件夹中
FlightGear编译
打开cmake-gui
设置如下
Where is the source code设置为C:/FlightGear/flightgear-2.8.0
Where to build the binaries设置为C:/FlightGear/flightgear-build
CMAKE_INSTALL_PREFIX设置为C:/FlightGear/install/msvc100/FlightGear
SIMGEAR_INCLUDE_DIR设置为C:/FlightGear/install/msvc100/SimGear/include
点击Configure直至Generate可用,点击Generate生成工程文件
用VS打开C:\FlightGear\flightgear-build下的工程文件FlightGear.sln
解决方案配置选择Release
点击F7生成解决方案
下面需要配置环境变量
在Path里添加C:\FlightGear\install\msvc100\OpenSceneGraph\bin;C:\FlightGear\3rdParty\bin
修改完环境变量后需要重启电脑以生效
继续打开VS工程,将fgfs设置为启动项
打开fgfs的工程属性,配置属性-调试-命令参数,添加--fg-root=C:\FlightGear\data
按F5运行程序即可

FlightGear2.8.0 + OSG3.0.1 VS2010编译指南-8480 FlightGear编译指南.pdf (1011.51 KB, 下载次数: 33)
发表于 2014-4-17 16:53:27 | 显示全部楼层
看贴回复捞积分
既学习又高兴
发表于 2014-12-30 17:14:42 | 显示全部楼层
按照这个编译指导一步步来的,发现没有fgrun.exe,这是为啥啊
发表于 2015-2-11 20:58:05 | 显示全部楼层
CMake Error at C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindOpenSceneGraph.cmake:199 (message):
  ERROR: Version 3.0.0 or higher of the OSG is required.  Version ..  was
  found.

按楼主教程编译,出现上面错误,我OSG是3.0.1   cmake是2.8.9版本,大概是啥原因呐?
发表于 2015-2-11 20:59:16 | 显示全部楼层
补充:我下载的是OSG的二进制吗!跳过了OSG的编译步骤
发表于 2016-4-1 14:24:59 | 显示全部楼层
问什么我在用CMAKE生成simgear的时候出现boost错误,

NOTE: boost::test-based targets and tests cannot be added: boost >= 1.34.0 required but not found. (found: '' want >=103400) ENABLE_TESTS disabled, so continuing anyway.
CMake Error at D:/cmake-3.5.1-win32-x86/share/cmake-3.5/Modules/FindBoost.cmake:1657 (message):
  Unable to find the requested Boost libraries.

  Unable to find the Boost header files.  Please set BOOST_ROOT to the root
  directory containing Boost or BOOST_INCLUDEDIR to the directory containing
  Boost's headers.
Call Stack (most recent call first):
  CMakeLists.txt:193 (find_package)
发表于 2017-5-28 10:20:48 | 显示全部楼层
新手上路,感谢分享!
发表于 2018-4-1 18:47:37 | 显示全部楼层

谢谢楼主,学习学习!
您需要登录后才可以回帖 登录 | 加入联盟

本版积分规则

快速回复 返回顶部 返回列表