Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt creator 9.0.1 Header file QtNetwork file not found.
Qt 6.11 is out! See what's new in the release blog

Qt creator 9.0.1 Header file QtNetwork file not found.

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 5.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John Telek
    wrote on last edited by Chris Kawa
    #5

    My CmakeLists

    cmake_minimum_required(VERSION 3.5)
    
    project(TCOM3 VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Network Widgets)
    find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
    
    
    
    set(PROJECT_SOURCES
            main.cpp
            mainwindow.cpp
            mainwindow.h
            mainwindow.ui
    )
    
    if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
        qt_add_executable(TCOM3
            MANUAL_FINALIZATION
            ${PROJECT_SOURCES}
        )
    # Define target properties for Android with Qt 6 as:
    #    set_property(TARGET TCOM3 APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
    #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
    # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
    else()
        if(ANDROID)
            add_library(TCOM3 SHARED
                ${PROJECT_SOURCES}
            )
    # Define properties for Android with Qt 5 after find_package() calls as:
    #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
        else()
            add_executable(TCOM3
                ${PROJECT_SOURCES}
            )
        endif()
    endif()
    
    target_link_libraries(TCOM3 PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
    
    set_target_properties(TCOM3 PROPERTIES
        MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE TRUE
    )
    
    install(TARGETS TCOM3
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
    
    if(QT_VERSION_MAJOR EQUAL 6)
        qt_finalize_executable(TCOM3)
    endif()
    

    Cheers

    1 Reply Last reply
    0
    • kkoehneK Offline
      kkoehneK Offline
      kkoehne
      Moderators
      wrote on last edited by
      #6

      @John-Telek said in Qt creator 9.0.1 Header file QtNetwork file not found.:

      /home/user/Code/QT/TCOM3/CMakeLists.txt:15: error: Cannot specify link libraries for target "mytarget" which is not built by this project.

      You need to replace mytarget with the CMake target that you're defining in the CMakeLists.txt file. That is, if you have a line like

      add_executable(somename ...)
      
        or add_library(somename ...)
      

      Then somename is the CMake target name you want to use, instead of mytarget.

      Director R&D, The Qt Company

      M 1 Reply Last reply
      1
      • J Offline
        J Offline
        John Telek
        wrote on last edited by
        #7

        I did and still get this error.

        /home/user/Code/QT/TCOM3/CMakeLists.txt:15: error: Cannot specify link libraries for target "TCOM3" which is not built by this project.

        The name is correct. And I still dont understand why #include <QtNetwork> and #include <QTcpSocket> only work in the examples.

        Cheers

        jsulmJ 1 Reply Last reply
        0
        • J John Telek

          I did and still get this error.

          /home/user/Code/QT/TCOM3/CMakeLists.txt:15: error: Cannot specify link libraries for target "TCOM3" which is not built by this project.

          The name is correct. And I still dont understand why #include <QtNetwork> and #include <QTcpSocket> only work in the examples.

          Cheers

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #8

          @John-Telek Please post your current CMakeLists.txt file.
          "And I still dont understand why #include <QtNetwork> and #include <QTcpSocket> only work in the examples" - did you compare your CMakeLists.txt with the one from example?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • J Offline
            J Offline
            John Telek
            wrote on last edited by
            #9

            Now none of my base code will compile. Keep getting a Ninja -C error.

            JT

            jsulmJ 1 Reply Last reply
            0
            • J John Telek

              Now none of my base code will compile. Keep getting a Ninja -C error.

              JT

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #10

              @John-Telek Make a complete rebuild: delete everything in build folder (including hidden files), run CMake and build.
              In case of error message post it here.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • kkoehneK kkoehne

                @John-Telek said in Qt creator 9.0.1 Header file QtNetwork file not found.:

                /home/user/Code/QT/TCOM3/CMakeLists.txt:15: error: Cannot specify link libraries for target "mytarget" which is not built by this project.

                You need to replace mytarget with the CMake target that you're defining in the CMakeLists.txt file. That is, if you have a line like

                add_executable(somename ...)
                
                  or add_library(somename ...)
                

                Then somename is the CMake target name you want to use, instead of mytarget.

                M Offline
                M Offline
                micha_eleric
                wrote on last edited by
                #11

                @kkoehne said in Qt creator 9.0.1 Header file QtNetwork file not found.:

                @John-Telek said in Qt creator 9.0.1 Header file QtNetwork file not found.:

                /home/user/Code/QT/TCOM3/CMakeLists.txt:15: error: Cannot specify link libraries for target "mytarget" which is not built by this project.

                You need to replace mytarget with the CMake target that you're defining in the CMakeLists.txt file. That is, if you have a line like

                add_executable(somename ...)
                
                  or add_library(somename ...)
                

                Then somename is the CMake target name you want to use, instead of mytarget.

                please explain "somename" more

                C 1 Reply Last reply
                0
                • M micha_eleric

                  @kkoehne said in Qt creator 9.0.1 Header file QtNetwork file not found.:

                  @John-Telek said in Qt creator 9.0.1 Header file QtNetwork file not found.:

                  /home/user/Code/QT/TCOM3/CMakeLists.txt:15: error: Cannot specify link libraries for target "mytarget" which is not built by this project.

                  You need to replace mytarget with the CMake target that you're defining in the CMakeLists.txt file. That is, if you have a line like

                  add_executable(somename ...)
                  
                    or add_library(somename ...)
                  

                  Then somename is the CMake target name you want to use, instead of mytarget.

                  please explain "somename" more

                  C Offline
                  C Offline
                  ChrisW67
                  wrote on last edited by ChrisW67
                  #12

                  @micha_eleric "somename" is a placeholder for the name you gave CMake for your executable or library in CMakeLists.txt. This name will appear in one of these directives:

                  add_executable(somename  ...)
                  add_library(somename ....)
                  qt_add_executable(somename ....)
                  qt_add_library(somename ...)
                  

                  See Getting started with CMake

                  M 1 Reply Last reply
                  1
                  • C ChrisW67

                    @micha_eleric "somename" is a placeholder for the name you gave CMake for your executable or library in CMakeLists.txt. This name will appear in one of these directives:

                    add_executable(somename  ...)
                    add_library(somename ....)
                    qt_add_executable(somename ....)
                    qt_add_library(somename ...)
                    

                    See Getting started with CMake

                    M Offline
                    M Offline
                    micha_eleric
                    wrote on last edited by
                    #13

                    @ChrisW67 said in Qt creator 9.0.1 Header file QtNetwork file not found.:

                    @micha_eleric "somename" is a placeholder for the name you gave CMake for your executable or library in CMakeLists.txt. This name will appear in one of these directives:

                    add_executable(somename  ...)
                    add_library(somename ....)
                    qt_add_executable(somename ....)
                    qt_add_library(somename ...)
                    

                    See Getting started with CMake

                    i assumed that "somename" was a placeholder for project name, but gives same error, but with project name instead.

                    jsulmJ 1 Reply Last reply
                    0
                    • M micha_eleric

                      @ChrisW67 said in Qt creator 9.0.1 Header file QtNetwork file not found.:

                      @micha_eleric "somename" is a placeholder for the name you gave CMake for your executable or library in CMakeLists.txt. This name will appear in one of these directives:

                      add_executable(somename  ...)
                      add_library(somename ....)
                      qt_add_executable(somename ....)
                      qt_add_library(somename ...)
                      

                      See Getting started with CMake

                      i assumed that "somename" was a placeholder for project name, but gives same error, but with project name instead.

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #14

                      @micha_eleric Please show your current CMakeLists.txt file.
                      Also, you should do complete rebuild after changing CMakeLists.txt

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt
                      • Unsolved