這是我的 CMakelists.txt 檔案。
cmake_minimum_required(VERSION 3.0.2)
project(osm_map)
find_package(catkin REQUIRED COMPONENTS rviz)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
set(QT_LIBRARIES Qt5::Widgets Qt5::Qml)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(SRC_FILES
src/core.cpp
)
add_library(${PROJECT_NAME} ${SRC_FILES})
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${catkin_LIBRARIES})
當我嘗試使用編譯我的專案時catkin_make -Wno-dev --only-pkg-with-deps osm_map,它似乎找到了 QT 的每個模塊(我還測驗了下面未顯示的其他模塊)但沒有找到 QML。錯誤資訊:
CMake Error at osm_map/CMakeLists.txt:53 (target_link_libraries):
Target "osm_map" links to:
Qt5::Qml
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
QT QML 安裝在我的系統和路徑上/usr/include/x86_64-linux-gnu/qt5/QtQml,并包含必要的標頭。以及為什么我可以這樣做?對 QT的find_package呼叫應該找到 QT 附帶的所有庫和標頭,也許這是 QML 無法正常作業的部分?
uj5u.com熱心網友回復:
問題出在你
find_package(Qt5 COMPONENTS Widgets REQUIRED)
在這里你問 CMake 你想要 Qt5 的 Widgets 組件但是你告訴它鏈接到你沒有要求的 Qml。
您應該將其更改為以下內容:
find_package(Qt5 COMPONENTS Widgets Qml REQUIRED)
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/537522.html
