qt5.14 加载ogsearth 遇到的坑

环境:vs2022 qt5.14
按照网上的教程先是编译库,编译osg 3.6.5 成功了,显示了牛,
按照该方法,成功了
后续编译ogsqt 以及ogsearth 一直失败,报错
该教程感觉太复杂了,放弃了
后来参考的别人编译好的库
博客地址
下载地址下载已经编译好的各种库,然后开始qt嵌入显示地球。
开始参考网上的例子(dll文件要拷到exe文件目录下),地球显示是白的,后来将ogsearth源码中的data文件夹拷入exe目录,结果正常了(原因是qt提示exe目录下data/woorld.tif 没有打开,然后搜索一下正好data文件夹中有这个文件,直接就拷贝过来了,结果ok了,刚开始学,好多东西都不清楚是干啥的,瞎猫碰对了)。

qt显示地球用的是此处的,pro文件是自己写的

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    osgshowwidget.cpp
HEADERS += \
    osgshowwidget.h

FORMS += \
    osgshowwidget.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
#D:/2024/demo/Sniffer-Master/Lib/

win32:CONFIG(release, debug|release): LIBS += -L$$$$PWD/../ogsearth/lib/ -losg  -losgDB -losgUtil  -losgViewer  -losgGA   -losgWidget   -lOpenThreads
else:win32:CONFIG(debug, debug|release): LIBS += -L$$$$PWD/../ogsearth/lib/ -losgd  -losgDBd -losgUtild  -losgViewerd  -losgGAd  -losgWidgetd -lOpenThreadsd
else:unix: LIBS += -L$$$$PWD/../ogsearth/lib/ -losg  -losgDB -losgUtil  -losgViewer  -losgGA  -losgWidget   -lOpenThreads

INCLUDEPATH += $$PWD/../ogsearth/include
DEPENDPATH += $$PWD/../ogsearth/include



win32:CONFIG(release, debug|release): LIBS += -L$$$$PWD/../ogsearth/osgQt-osg3.7.0/lib/ -losgQOpenGL
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../ogsearth/osgQt-osg3.7.0/lib/ -losgQOpenGLd
else:unix: LIBS += -L$$PWD/../ogsearth/osgQt-osg3.7.0/lib/ -losgQOpenGL

INCLUDEPATH += $$PWD/../ogsearth/osgQt-osg3.7.0/include
DEPENDPATH += $$PWD/../ogsearth/osgQt-osg3.7.0/include




win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../ogsearth/osgearth3.4/lib/ -losgEarth
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../ogsearth/osgearth3.4/lib/ -losgEarthd
else:unix: LIBS += -L$$PWD/PWD/../ogsearth/osgearth3.4/lib/ -losgEarth

INCLUDEPATH += $$PWD/../ogsearth/osgearth3.4/include
DEPENDPATH += $$PWD/../ogsearth/osgearth3.4/include








#include <QCoreApplication>
#include <QApplication>
#include <QDir>
#include "osgshowwidget.h"
#include <osgEarth/Map>
#include <osgEarth/MapNode>
#include <osgEarth/EarthManipulator>
#include <osgEarth/MapNode>
#include <osgEarth/TMS>
#include <osgEarth/EarthManipulator>
#include <osg/ArgumentParser>
#include <osgViewer/Viewer>

#include <QWidget>
#include <osgViewer/Viewer>
#include <osg/Node>
#include <osgDB/ReadFile>
#include <osgGA/TrackballManipulator>
#include<osgGA/FlightManipulator>
#include <osgViewer/View>
#include <osgQOpenGL/osgQOpenGLWidget>

#include <osg/Timer>
#include <osg/ArgumentParser>
#include <osgGA/CameraManipulator>

int main(int argc, char *argv[])
{
        QApplication a(argc, argv);

//    // 获取可执行文件的目录

   osgShowWidget w;
   w.show();


    // 初始化osgViewer
    // 初始化osgEarth
//    osgEarth::initialize();
//    osg::ArgumentParser args(&argc, argv);

//    // 创建Viewer实例
//    osgViewer::Viewer viewer(args);

//    // 使用相对于exe的相对路径来构建.earth文件的完整路径
//    QString relativeEarthFilePath = "Maps/ocean.earth";  // 请替换为你实际的.earth文件相对路径
//    QString earthFilePath = exeDir + "/" + relativeEarthFilePath;

//    // 请替换为你实际的.earth文件路径
//    osg::ref_ptr<osg::Node> earthNode = osgDB::readNodeFile(earthFilePath.toStdString());

//    if (!earthNode) {
//        std::cerr << "Failed to load .earth file: " << earthFilePath.toStdString() << std::endl;
//        return -1;  // 如果加载失败,返回错误码
//    }

//    // 设置场景数据为加载的.earth文件
//    viewer.setSceneData(earthNode.get());

//    // 设置地球操控器
//    viewer.setCameraManipulator(new osgEarth::Util::EarthManipulator(args));

//    // 运行Viewer
//    return viewer.run();



    return a.exec();
}

需要拷贝的dll文件,osgPu。。。文件夹中的也要考出来
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述入图片描述
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

weixin_45247650

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值