3

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.

0

1 Answer 1

3

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.

For Qt >= 6.10, you actually have to add CorePrivate as a separate component (see 6.10 Build System Changes


Source: Qt Documentation — Qt Core Private C++ Classes.

Sign up to request clarification or add additional context in comments.

1 Comment

This answer will no longer be accurate after Qt 6.10 is released.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.