关于使用vcpkg下载osgearth遇到的问题

在使用vcpkg安装osgearth时遇到了一些问题,记录一下。

安装vcpkg后使用vcpkg install osgearth:x64-windows安装好osgearth并且导入项目使用时,发现无法运行官方文档中示例的main.cpp 

官方文档地址:https://docs.osgearth.org/en/latest/install.html

示例CMakeLists.txt

cmake_minimum_required(VERSION 3.7)

project(
    myApp
    VERSION 0.1.0
    LANGUAGES CXX C
)

find_package(OpenSceneGraph REQUIRED COMPONENTS osg osgDB osgGA osgUtil osgViewer)

find_package(osgEarth CONFIG REQUIRED)

add_executable(myApp main.cpp)

target_link_libraries(myApp PRIVATE osgEarth)
target_link_libraries(myApp PRIVATE ${OPENSCENEGRAPH_LIBRARIES})

install(TARGETS myApp RUNTIME DESTINATION bin)

示例main.cpp

#include <osgEarth/MapN
ode>
#include <osgEarth/TMS>
#include <osgEarth/EarthManipulator>

#include <osg/ArgumentParser>
#include <osgViewer/Viewer>

int main(int argc, char** argv)
{
    osgEarth::initialize();
    
    osg::ArgumentParser args(&argc, argv);
    osgViewer::Viewer viewer(args);
    
    auto imagery = new osgEarth::TMSImageLayer();
    imagery->setURL("https://readymap.org/readymap/tiles/1.0.0/7/");
    
    auto mapNode = new osgEarth::MapNode();
    mapNode->getMap()->addLayer(imagery);
    
    viewer.setSceneData(mapNode);
    viewer.setCameraManipulator(new osgEarth::EarthManipulator(args));
    
    return viewer.run();
}

查阅GitHub后发现该问题在osgearth3.5已经修复,而vcpkg使用的osgearth是3.4版本,因此需要自行去下载源码编译。

GitHub页面:gwaldron/osgearth: A 3D Mapping Engine & SDK for OpenSceneGraph. (github.com)

ps:修改一下,之前发布的有误,下面的方法是安装osgearth3.5依赖库的方法

这里写一种使用vcpkg安装osgearth3.5依赖库的方法,

下载上面GitHub的Releases 13源码,打开vcpkg所在的命令行,执行

vcpkg install --x-manifest-root=E:\gitproject\osgearth-osgearth-3.5\vcpkg

注意--x-manifest-root=后面跟着的E:\gitproject\osgearth-osgearth-3.5\vcpkg是你下载的源码解压缩后vcpkg.json的文件地址,然后等待编译完成

最后在上述目录下会生成vcpkg_installed,包括所有相关的依赖库,然后使用cmakegui编译生成osgearth

这是新发布的编译osgearth3.5的方法:

使用cmake和vcpkg构建最新osgearth3.5-CSDN博客

  • 19
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值