简体   繁体   English

从 Qt6 链接 CorePrivate

[英]Link CorePrivate from Qt6

I am writing a server using QtHttpServer (from Qt6).我正在使用 QtHttpServer(来自 Qt6)编写服务器。 It's time to implement chats for the system using web sockets, but it hasn't been added to Qt6 yet.是时候用web sockets为系统实现聊天了,但是Qt6还没有加入。 I see two ways out – either use long-pulling instead of web sockets, or download the web sockets code from qt5 and add it to the project.我看到两种出路——要么使用长拉而不是 web sockets,要么从 qt5 下载 web sockets 代码并将其添加到项目中。 I decided to try the second option first, but I ran into a problem – the project uses QObjectPrivate.我决定首先尝试第二个选项,但我遇到了一个问题——该项目使用 QObjectPrivate。 I understand that it is part of the CorePrivate library.我知道它是 CorePrivate 库的一部分。 I tried to link it, but it didn't work.我试图链接它,但它没有用。 Can you tell me if this can be solved somehow in Qt6?你能告诉我这是否可以在 Qt6 中以某种方式解决吗?

cmake: cmake:

find_package(Qt6 COMPONENTS CorePrivate Core Network Sql HttpServer REQUIRED)

...

add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES})
target_link_libraries(${PROJECT_NAME} Qt6::CorePrivate Qt6::Core Qt6::Network Qt6::Sql Qt6::HttpServer)

error:错误:

CMake Error at CMakeLists.txt:12 (find_package):
  Found package configuration file:

    /usr/local/opt/qt/lib/cmake/Qt6/Qt6Config.cmake

  but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
  FOUND.  Reason given by package:

  Failed to find Qt component "CorePrivate" config file at ""

  Failed to find Qt component "Core" config file at ""

  Failed to find Qt component "Network" config file at ""

  Failed to find Qt component "Sql" config file at ""

  Failed to find Qt component "HttpServer" config file at ""

Without CorePrivate cmake runs successfully.没有 CorePrivate cmake 成功运行。

It seems CorePrivate is part of the Core component so you don't need to add it in your find_package .似乎 CorePrivate 是核心组件的一部分,因此您无需将其添加到您的find_package中。

All you need to do is to call Qt6::CorePrivate in target_link_libraries .您需要做的就是在 target_link_libraries 中调用Qt6::CorePrivate target_link_libraries

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM