OSG Win7 + VS2015 编译

1. 准备

建立目标树

OpenSceneGraph-VERSION (VERSION替换为版本号)
OpenSceneGraph-VERSION3rdParty (把依赖库放在此目录)

http://www.openscenegraph.org/index.php/download-section/dependencies
OpenSceneGraph-VERSIONOpenSceneGraph(源代码放在此目录)

2. 三方依赖库构建

  1. https://github.com/bjornblissing/osg-3rdparty-cmake下载CMake脚本(Download the CMake scripts from this repository).
  2. 下载依赖库源文件. Download the source for the dependencies you would like to use from their respective location as specified below.
  3. 打开CMake GUI, 选择CMake脚本所在目录, 指定生成库输出目录. Start the CMake GUI and select the directory with the CMake scripts as your source directory. Use any desired output directory as binary directory.
  4. 在CMake GUI中按"Configure". Press Configure inside the CMake GUI.
  5. 填写依赖库源代码目录, 再按"Configure". 重复配置, 直到没有错误和警告为止. Fill in the location of the downloaded sources of your desired dependencies and press "Configure" again. Repeat until there is no more errors and warnings in CMake.
  6. Generate 在输出目录中生成VS解决方案文件. Press Generate inside the CMake GUI. This will generate solution file inside your binary directory.
  7. 在VS IDE中打开解决方案文件. Open the solution file in your IDE.
  8. 编译ALL_BUILD项目. Build the ALL_BUILD project for both debug and release.
  9. 编译INSTALL项目. Build the INSTALL project for both debug and release.

In your binary directory there will now be a folder named 3rdParty with a sub-folder named after your target platform. Inside this folder there should be all your headers and libraries.

3. 构建OpenSceneGraph解决方案

在CMake GUI中选择OpenSceneGraph 源文件目录, 设置CMake配置输出目录.

ACTUAL_3RDPARTY_DIR  3rdParty编译库集目录

CMAKE_INSTALL_PREFIX  OpenSceneGraph 编译成果安装目录

 BUILD_OSG_EXAMPLES     是否编译示例

Once the sources and dependencies are in place you need to generate the Visual Studio solution and project files. This is done with CMake. Download it at http://www.cmake.org/HTML/Download.html.

Start the CMake GUI once it's installed, and select root OpenSceneGraph directory in the "Where is the source code" field. The same directory needs to be put into the "Where to build the binaries" field. If you like to do out-of-source builds, you can add uild to the end. Then click Configure.

You can then customize your build. The red lines in the CMake window indicate new variables that you may want to fill out or change, but most are optional. Some variables will be filled in automatically (such as ACTUAL_3RDPARTY_DIR, if you followed the directory structure above). I typically enable BUILD_OSG_EXAMPLES and set CMAKE_INSTALL_PREFIX to the OpenSceneGraph directory so that the binaries are installed in OpenSceneGraphin. You can also set it to somewhere else if you want to keep your source tree clean.

4. OpenSceneGraph编译

打开OpenSceneGraph解决方案进行编译

  1. 编译ALL_BUILD项目. Build the ALL_BUILD project for both debug and release.
  2. 编译INSTALL项目. Build the INSTALL project for both debug and release.
原文地址:https://www.cnblogs.com/yaoyu126/p/6156196.html