繁体   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