1. 程式人生 > >vs2013 Qt5.7編譯osgearth2.7遇到的問題及解決辦法

vs2013 Qt5.7編譯osgearth2.7遇到的問題及解決辦法

網上編譯osgearth的過程很多,這裡就不再做記錄了,只把編譯過程中遇到的問題記錄下來,以便以後有人再次遇到同樣的問題,不用再走彎路。

一、編譯環境

Vs2013Qt5.7osg3.2osgearth2.7

二、cmake生成vs時的警告

CMake Warning (dev) in src/osgEarthQt/CMakeLists.txt:Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in src/osgEarthQt/CMakeLists.txt:Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in src/osgEarthQt/CMakeLists.txt:Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties.Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy

command to set the policy and suppress this warning.This warning is for project developers. Use -Wno-dev to suppress it.

解決辦法:

osgEarthQt/CMakeList.txt檔案中新增如下程式碼即可消除警告

if(COMMAND cmake_policy)

    # Works around warnings libraries linked against that don't

    # have absolute paths (e.g. -lpthreads)

    cmake_policy(SET CMP0003 NEW)

    # Works around warnings about escaped quotes in ADD_DEFINITIONS

    # statements.

    cmake_policy(SET CMP0005 OLD)

    IF(COMMAND cmake_policy)

            IF(${CMAKE_MAJOR_VERSION} GREATER 2)

                # Qt5 qt5_use_modules usage was causing "Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties." warnings

                cmake_policy(SET CMP0043 NEW)

            ENDIF()

    ENDIF()

    # disable autolinking to qtmain as we have our own main() functions (new in Qt 5.1)

    if(NOT "${CMAKE_VERSION}" VERSION_LESS 3.6.0)

        cmake_policy(SET CMP0020 OLD)

    endif(NOT "${CMAKE_VERSION}" VERSION_LESS 3.6.0)

endif(COMMAND cmake_policy)

三、編譯osgearthQt庫時在moc_XXX.cpp中缺少osgEarth、QtGui名稱空間

主要原因在於cmake生成Qt時自動生成了moc_xxx.cpp檔案,但是沒有將工程的.h標頭檔案新增進去,導致程式在編譯時無法找到名稱空間以及相應的成員方法。

解決辦法

方法1、 在moc_xxx.cpp中新增osgearthQt庫工程的對應標頭檔案,這個辦法比較笨,但是方便。

方法2、 在進行cmake生成vs工程之前註釋掉osgearthQt工程CMakeLists.txt檔案如下幾行,不讓在cmake時生成moc_xxx.cpp檔案,因為moc_xxx.cpp檔案會在編譯工程時自動生成。

# Header files that need moc'd

#set(LIB_MOC_HDRS

#    AnnotationDialogs

#    AnnotationListWidget

#   AnnotationToolbar

#   CollapsiblePairWidget

#   DataManager

#   LayerManagerWidget

#  LOSControlWidget

#    LOSCreationDialog

#    MapCatalogWidget

#    TerrainProfileGraph

#    TerrainProfileWidget

#    ViewerWidget

#)

其次在註釋掉如上程式碼後再進行cmake生成vs工程,再次編譯osgearthQt工程還是不能通過。

錯誤如下:

錯誤 1 error LNK2001: 無法解析的外部符號 "public: virtual struct QMetaObject const * __thiscall osgEarth::QtGui::BaseAnnotationDialog::metaObject(void)const " ([email protected]@[email protected]@@[email protected]@XZ) AnnotationDialogs.obj osgEarthQt

解決辦法:

主要原因:沒能生成moc_xxx.cpp檔案。

修改vs配置,右擊osgearthQt標頭檔案-----》屬性,要對有Q_OBJECT標頭檔案的類都要進行如下配置。

 

修改項型別“不參與生成”為“自定義生成工具”

 

配置“自動定義生成工具”,主要配置“命令列”、“輸出”

 

命令列:

"$(QTDIR)\moc.exe"  "%(FullPath)" -o "$(ConfigurationName)\moc_%(Filename).cpp"  -D_WINDOWS -DUNICODE -DWIN32 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNOMINMAX -D_UNICODE  "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtCore" "-I.\debug" "-I." "-I$(QTDIR)\." "-I$(QTDIR)\include\QtOpenGL"

輸出:

Debug\moc_ViewWidget.cpp;%(Outputs)

這裡注意:首先要配置環境變數:QTDIR

四、執行osgearth_qtd.exe時報錯如下:

Error: glGenBuffers not supported by OpenGL driver

Error: glBindBuffer not supported by OpenGL driver

Error: glBufferData not supported by OpenGL driver

Error: glBufferData not supported by OpenGL driver

Error: glBufferData not supported by OpenGL driver

Error: glBufferData not supported by OpenGL driver

Error: glBufferData not supported by OpenGL driver

Error: glBufferData not supported by OpenGL driver

Error: glBufferData not supported by OpenGL driver

Error: glGenBuffers not supported by OpenGL driver

Error: glBindBuffer not supported by OpenGL driver

Error: glBufferData not supported by OpenGL driver

Error: glBufferData not supported by OpenGL driver

Error: glBindBuffer not supported by OpenGL driver

Error: glBindBuffer not supported by OpenGL driver

主要原因:電腦顯示卡驅動的opengl版本太低。Intel(R) HD Graphics 300 整合顯示卡的opengl版本比較低,導致如上錯誤。禁止整合顯示卡,電腦會自動切換到獨立顯示卡NVIDIA GreForce GT 520M,再次執行程式沒有問題。

 執行結果如下:


相關推薦

vs2013 Qt5.7編譯osgearth2.7遇到的問題解決辦法

網上編譯osgearth的過程很多,這裡就不再做記錄了,只把編譯過程中遇到的問題記錄下來,以便以後有人再次遇到同樣的問題,不用再走彎路。 一、編譯環境 Vs2013、Qt5.7、osg3.2、osgearth2.7 二、cmake生成vs時的警告 CMake Warning

於g2o新版本編譯出錯的原因解決辦法

在githubg2o的github地址上面down了最新的版本進行安裝, 編譯十四講第六講的程式碼出錯, 報錯資訊: /home/hri/SLAM/slambook/ch6/g2o_curve_fitting/main.cpp: In function ‘

linux CentOS x64 裡php原始碼編譯出錯參見情況解決辦法

configure: error: xml2-config not found. Please check your libxml2 installation. yum install libxml2-devel.x86_64 configure: error: C

centos 7 編譯 python3.7.0

str error module error: ctu err pro init lin 安裝編譯所需庫 yum install -y libffi-devel 編譯安裝 cd /usr/local/src wget https://www.python.org/ftp/p

Centos 7 編譯php 7.2.10

get pcre php 7 sysv reg make ttext etc socket 步驟一:安裝依賴 yum install -y wget gcc gcc-c++ gd-devel zlib-devel libjpeg-devel libpng-devel li

CentOS 7 常見命令、問題解決方式

一、ifconfig命令無法找到,提示bash: ifconfig: command not found            分析問題            su 切換到root使用者            1. [[email protected] /]# w

Centos 7.3 (1611)使用遇到問題解決辦法集錦

1.host smbus controller not enable 解決:在/etc/modprobe.d/blacklist.conf中新增blacklist i2c_piix4,重啟 2.intel_rapl: no valid rapl domain

MySQL Server 5.7安裝遇到的問題解決

遇到問題: 我試過 mysqld –remove 和mysqld –install 也試過 mysqld –initialize 先初始化data目錄 仍然是服務正在啟動,服務無法啟動。如

編譯你的第一個Java虛擬機--Centos 7 編譯openJdk1.7源碼

... 沒有 相關 rmdir cnblogs int 了解 grep rac 一、前言 最近在看《深入java虛擬機》,看完後,打算自己實際編譯一個jvm出來看看,實踐一下。 書上提到了Oracle JDK和OpenJdk的關系,Oracle Jdk7 和OpenJd

winrar 解壓 hadoop-2.7.3-src.tar.gz 失敗解決辦法

問題#1: GetTaskAttemptCompletionEventsRequestPBImpl.java 解壓失敗 ------------------------------------------------------------- !   F:\解包測試\ha

python3.7中mysqlclient安裝錯誤的解決辦法

http text 14. 如何選擇 status 圖片 visual ESS shadow 近期,安裝mysqlclient一直報錯,導出找資料,琢磨,大致解決如下:一、錯誤提示_mysql.c(29): fatal error C1083: 無法打開包括文件: “mys

Linux下編譯PHP常見錯誤解決方法

locate freetype evel distrib 常見 expec fin install erro 1、configure: error: xml2-config not found. Please check your libxml2 installation.

mysql-所問題解決辦法

1.1366錯誤 導致1366錯誤的原因是:資料庫此欄位的字符集與整理字符集不同。 只需要將資料庫的字符集、表的字符集、各欄位的字符集調整設為相同即可。 通過 show full columns from 表名 可以檢視各欄位的字元 通過 show full columns from

UBUNTU16 64位編譯VLC-2.2.8/4 WIN32應用 遇到的問題解決辦法

主要參考: https://blog.csdn.net/longji/article/details/52304590  vlc-2.2.4 交叉編譯 UbuntuX64_1604_Desktop 編譯windows版本vlc 1,make prebuil

Autoware在Ubuntu14.04中編譯安裝遇到的一些問題解決辦法

cv_brige依賴boost 1.54 我之前安裝的boost1.66,貌似cv_brige依賴boost1.54,導致編譯出錯。 解決辦法:解除安裝安裝的boost1.66之後,重新下載boost1.54編譯安裝即可。 解除安裝boost:boost庫一般安裝

使用ffmpeg庫編譯錯誤解決辦法

一、FFmpeg原始碼下載與編譯 # wget http://www.ffmpeg.org/releases/ffmpeg-0.5.13.tar.bz2 # tar -jxvf ffmpeg-0.5.13.tar.bz2 # vim ffmpeg_configure.sh .

Qt5.9.1配置OpenCV3.4錯誤解決辦法(mingw32)

在用cmake編譯opencv3.4.1出現了不少錯誤,用的編譯器是mingw,報過幾種錯誤,現將其整理如下: 配置Qt與opencv可以參考官方文件: qt with opencv.  1. 官方文件中提到的取消勾選ENABLE_PRECOMPILED_HEADERS和

Android原始碼編譯環境搭建問題解決方案小結

1. ImportError: No module named bz2 for Python 2.7.2 (1)$ source build/envsetup.sh (2)$ lunch aosp_arm-eng (3)$ mak

安卓7.0 WebView 載入網頁空白解決辦法

mainWebView.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(W

Glide 3.7.0 載入https 圖片的解決辦法

需要的依賴如下 compile 'com.squareup.okhttp3:okhttp:3.3.1' compile 'com.github.bumptech.glide:glide:3.7.0' 需要以下三個類 OkHttpStr