簡體   English   中英

從 Qt6 鏈接 CorePrivate

[英]Link CorePrivate from Qt6

我正在使用 QtHttpServer(來自 Qt6)編寫服務器。 是時候用web sockets為系統實現聊天了,但是Qt6還沒有加入。 我看到兩種出路——要么使用長拉而不是 web sockets,要么從 qt5 下載 web sockets 代碼並將其添加到項目中。 我決定首先嘗試第二個選項,但我遇到了一個問題——該項目使用 QObjectPrivate。 我知道它是 CorePrivate 庫的一部分。 我試圖鏈接它,但它沒有用。 你能告訴我這是否可以在 Qt6 中以某種方式解決嗎?

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)

錯誤:

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 ""

沒有 CorePrivate cmake 成功運行。

似乎 CorePrivate 是核心組件的一部分,因此您無需將其添加到您的find_package中。

您需要做的就是在 target_link_libraries 中調用Qt6::CorePrivate target_link_libraries

暫無
暫無

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

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