简体   繁体   中英

Link CorePrivate from Qt6

I am writing a server using QtHttpServer (from Qt6). It's time to implement chats for the system using web sockets, but it hasn't been added to Qt6 yet. 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. I decided to try the second option first, but I ran into a problem – the project uses QObjectPrivate. I understand that it is part of the CorePrivate library. I tried to link it, but it didn't work. Can you tell me if this can be solved somehow in 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)

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.

It seems CorePrivate is part of the Core component so you don't need to add it in your find_package .

All you need to do is to call Qt6::CorePrivate in target_link_libraries .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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