OSVR-Core编译

OSVR-Core编译

OSVR-Core开源项目地址,点击这里。
编译过程中,使用到多个开源库,编译起来还是花了不少时间(跟之前vlc-android编译起来差不多,费时费力),osvr-core不是一定要求每个人都要编译,官网提供编译好的应用程序使用,不过对于开发者来说,建议还是编译一次这个环境,一方面可以了解这个项目使用到了哪些开源项目,另一方面后续为自己的HMD设备制作plugin时遇到复杂问题,可以从源码添加log来定位问题。

编译环境说明

  • 系统:win7 64位 SP1
  • 编译工具:
    • Visual Studio 2015 update3 (官网推荐VS2013,并且明确说明VS2012版本和VS2015update1有BUG)
    • Git(官网下载)
    • CMake(>=3.0,我这里用的是最新的3.6.1,官网下载)
    • Boost库(>=1.44,这里使用的是1.61,官网下载,或我使用的上传微云网盘)
    • opencv(2.4.x,这里使用2.4.13,官网下载)
    • SDL2.0(2.0.4,官网下载)
    • 获取osvr-core源代码:
      git clone –recursive https://github.com/OSVR/OSVR-Core.git(其中”–recursive”参数同时可以拉取子模块的代码,如hidapi,jsoncpp,vrpn等)
    • 获取libfunctionality源代码:
      git clone https://github.com/OSVR/libfunctionality.git
    • 获取jsoncpp源代码:
      git clone https://github.com/open-source-parsers/jsoncpp.git

编译OSVR依赖库

  • 编译libfunctionality
    • 打开CMake,设置源代码和生成路径,然后点击“Configure”按钮:
      OSVR-Core编译_第1张图片
    • 生成”build“文件夹,点击”yes“:
      OSVR-Core编译_第2张图片
    • 选择编译器,这个要根据你使用的编译器来设定,我这里用的是VS2015 Update3 64位,点击”Finish”:
      OSVR-Core编译_第3张图片
      如果编译时有如下错误:
      OSVR-Core编译_第4张图片
      C和CXX编译器没有找到,这个是因为你的Visual Studio 2015没有安装C/C++部分组件:
      解决办法:打开”Microsft Visual Studio Community 2015”把组件装上。
      OSVR-Core编译_第5张图片
      OSVR-Core编译_第6张图片
      点击“Modify”按钮后,选择”select All”,我是勾选全部组件,点击 “Next”
      OSVR-Core编译_第7张图片
      这里更新大概要几个小时。
    • 更新完成后,再次运行CMake,点击”Configure”,返回配置完成(“Configuring done”),在点击”Generate”,返回生成完成(Generating done),如下所示:
      OSVR-Core编译_第8张图片
      此时,在之前设置的”build”文件夹内,就有“.sln”的VS工程文件:
      OSVR-Core编译_第9张图片
    • 打开sln工程文件,选择”release” “x64”版本(编译osvr-core所使用到的库,都需要编译为相同类型的版本,即都为Release或都为Debug,不能有些库编译为Release,另外一些用Debug,否则会导致一些很不好定位的错误!在这里费了很多时间!建议都先编译为release版本)。然后”Build”—“Build Solution”,生成所需的库文件:
      OSVR-Core编译_第10张图片
  • 编译jsoncpp
    使用CMake编译时,需要配置上此项”JSONCPP_WITH_CMAKE_PACKAGE”:
    OSVR-Core编译_第11张图片
    其他与上面”编译libfunctionality”的步骤一样(用Visual Studio编译时,记得选择release x64版本)。
  • 编译SDL2
    使用CMake与与上面”编译libfunctionality”的步骤一样。

编译OSVR-CORE

  • 配置OSVR的环境:
    OSVR-Core编译_第12张图片
    点击”Configure”会有很多错误。接下来就逐一解决
    • 错误1:Could NOT find SDL2 (missing: SDL2_LIBRARY SDL2_INCLUDE_DIR SDL2_SDLMAIN_LIBRARY)
      解决办法:CMAKE里设置SDL2的相关路径:
      这里写图片描述
    • 错误2:opencv相关错误:
      By not providing “FindOpenCV.cmake” in CMAKE_MODULE_PATH this project has
      asked CMake to find a package configuration file provided by “OpenCV”, but
      CMake did not find one.
      Could not find a package configuration file provided by “OpenCV” with any
      of the following names:
      OpenCVConfig.cmake
      opencv-config.cmake
      Add the installation prefix of “OpenCV” to CMAKE_PREFIX_PATH or set
      “OpenCV_DIR” to a directory containing one of the above files. If “OpenCV”
      provides a separate development package or SDK, be sure it has been
      installed.
      CMake Error at CMakeLists.txt:196 (message):
      BUILD_WITH_OPENCV is enabled, but OpenCV was not found! Either help CMake
      find OpenCV or disable BUILD_WITH_OPENCV.
      解决办法:设置opencv lib库路径:
      这里写图片描述
    • 错误3:jsoncpp相关
      CMake Error at F:/Program Files/CMake/share/cmake-3.6/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
      Could NOT find JsonCpp (missing: JsonCpp_INCLUDE_DIR JsonCpp_LIBRARY)
      Call Stack (most recent call first):
      F:/Program Files/CMake/share/cmake-3.6/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
      cmake/FindJsonCpp.cmake:334 (find_package_handle_standard_args)
      CMakeLists.txt:221 (find_package)
      解决办法
      OSVR-Core编译_第13张图片
    • 错误4:boost相关
      CMake Warning at F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:743 (message):
      Imported targets not available for Boost version
      Call Stack (most recent call first):
      F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:842 (_Boost_COMPONENT_DEPENDENCIES)
      F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:1395 (_Boost_MISSING_DEPENDENCIES)
      cmake-local/BoostTargets.cmake:25 (find_package)
      CMakeLists.txt:295 (include)
      CMake Warning at F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:743 (message):
      Imported targets not available for Boost version
      Call Stack (most recent call first):
      F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:842 (_Boost_COMPONENT_DEPENDENCIES)
      F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:1395 (_Boost_MISSING_DEPENDENCIES)
      cmake-local/BoostTargets.cmake:25 (find_package)
      CMakeLists.txt:295 (include)
      CMake Warning at F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:743 (message):
      Imported targets not available for Boost version
      Call Stack (most recent call first):
      F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:842 (_Boost_COMPONENT_DEPENDENCIES)
      F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:1395 (_Boost_MISSING_DEPENDENCIES)
      cmake-local/BoostTargets.cmake:25 (find_package)
      CMakeLists.txt:295 (include)
      CMake Warning at F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:743 (message):
      Imported targets not available for Boost version
      Call Stack (most recent call first):
      F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:842 (_Boost_COMPONENT_DEPENDENCIES)
      F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:1395 (_Boost_MISSING_DEPENDENCIES)
      cmake-local/BoostTargets.cmake:25 (find_package)
      CMakeLists.txt:295 (include)
      CMake Warning at F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:743 (message):
      Imported targets not available for Boost version
      Call Stack (most recent call first):
      F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:842 (_Boost_COMPONENT_DEPENDENCIES)
      F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:1395 (_Boost_MISSING_DEPENDENCIES)
      cmake-local/BoostTargets.cmake:25 (find_package)
      CMakeLists.txt:295 (include)
      CMake Warning at F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:743 (message):
      Imported targets not available for Boost version
      Call Stack (most recent call first):
      F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:842 (_Boost_COMPONENT_DEPENDENCIES)
      F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:1395 (_Boost_MISSING_DEPENDENCIES)
      cmake-local/BoostTargets.cmake:25 (find_package)
      CMakeLists.txt:295 (include)
      CMake Error at F:/Program Files/CMake/share/cmake-3.6/Modules/FindBoost.cmake:1753 (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):
      cmake-local/BoostTargets.cmake:25 (find_package)
      CMakeLists.txt:295 (include)
      解决办法:CMake—Add Entry,然后添加BOOST_ROOT和BOOST_LIBRARYDIR变量如下:
      OSVR-Core编译_第14张图片
      OSVR-Core编译_第15张图片
      勾选”Boost_USE_STATIC_LIBS”
      这里写图片描述
    • 错误5:Visual Studio 2015 编译报错:
      这里写图片描述
    • 错误6:Visual Studio 2015 编译报错:
      这里写图片描述
      这里写图片描述
      这里写图片描述
      解决办法:需要在”opencv”文件夹里,找到这3个文件,拷贝到指定路径。
      “opencv_highgui2413.dll“拷贝到”opencv\sources\build\bin\Release“路径下。
      “opencv_highgui2413.lib”和“opencv_core2413.lib”,拷贝到“opencv\sources\build\lib\release”路径下。
    • 最后编译成功:
      OSVR-Core编译_第16张图片

测试

使用默认的json配置来启动osv_server:
这里写图片描述
点击这里下载测试程序,运行应用“osvr-palace-v0.6.12.exe”,即可,如果osvr-core没运行起来,此应用汇直接报错。接上HMD设备,然后移动HMD,分屏画面会跟着移动(当然如果没接HMD设备,启动界面上不会有分屏)。

你可能感兴趣的:(开源库学习)