簡體   English   中英

CMake找不到QXmlSimpleReader

[英]CMake cannot find QXmlSimpleReader

我有一個C ++頭文件,其中包含以下幾行:

#include <QXmlSimpleReader>
#include <QXmlDefaultHandler>

我的cmake有以下幾行:

find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Xml REQUIRED)

運行CMake時,出現以下錯誤消息:

QXmlSimpleReader: No such file or directory
 #include <QXmlSimpleReader>

我究竟做錯了什么?

我猜您忘了鏈接到Qt5xml。 來自cmake 2.8.11及更高版本的文檔中的一個工作示例,已修改為針對Qt5Xml進行鏈接:

cmake_minimum_required(VERSION 2.8.11)

project(testproject)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

# Find the QtWidgets library
find_package(Qt5Xml)

# Tell CMake to create the helloworld executable
add_executable(helloworld WIN32 main.cpp)

# Use the Widgets module from Qt 5.
target_link_libraries(helloworld Qt5::Xml)

由於某些原因,它不會添加到項目包含目錄中。

將此添加到您的cmake

INCLUDE_DIRECTORIES( ${Qt5Xml_INCLUDE_DIRS} )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM