2024 -osgEarth+vs2022最新环境配置

引言

osgEarth的官方Getting started with osgEarth — osgEarth 3.5 documentation提供了两种方式来安装osgEarth,下面记录了使用第一种方式配置环境的方式

image-20240914181813639

1 安装vcpkg

在空白文件夹git一个vcpkg

git clone https://github.com/microsoft/vcpkg

image-20240914194923189

双击运行下面的文件,出现下面的图代表安装完成:

bootstrap-vcpkg.bat

image-20240914195205828

2 安装osgEarth

打开下面的文件夹

image-20240915154401612

修改gl2为gl3

image-20240915154322110

在vcpkg的根目录中以管理员模式(powershell也可以)打开CMD,并输入

vcpkg install osgearth:x64-windows

image-20240914212838455

等待安装:

image-20240914212851880

3 遇到的问题

在编译成功后,在cmd中输入

vcpkg integrate install

image-20240915093704851

将vcpkg中安装的bin加入到环境变量中:

image-20240915094136137

image-20240915094220721

测试官方的示例:

#include <osgEarth/MapNode>
#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();
}

由于gl.h的问题,需要加入预处理器WIN32

image-20240915094353905

发现出现了以下的问题:

image-20240915185823702

这是由于一些动态链接库并没有被导入bin中。

4 解决方案

将下列所有的dll文件移动到对应的release目录中,注意如果使用debug进行调试需要将vcpkg中debug目录下的dll和pdb文件移动到对应debug目录中。

image-20240915193330918

image-20240915193410203

最后成功运行:

image-20240915193732074

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值