Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator does not recognize omp.h even though the program compiles and it can be run with g++
Forum Updated to NodeBB v4.3 + New Features

QtCreator does not recognize omp.h even though the program compiles and it can be run with g++

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
4 Posts 3 Posters 520 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    Sampo Paukkonen
    wrote on last edited by
    #1

    I am using QtCreator and CMake for C++ development. My CMakeLists.txt file is currently the following:

    """

    cmake_minimum_required(VERSION 3.9)

    project(my_project LANGUAGES CXX)

    set(CMAKE_CXX_STANDARD 20)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(CMAKE_CXX_FLAGS_RELEASE "-O3")

    add_executable(my_project main.cpp)

    find_package(OpenMP)
    target_link_libraries(my_project PUBLIC OpenMP::OpenMP_CXX)

    """

    When I try to use OpenMPs functions such as the omp_get_num_threads(), I get the semantic issue:
    """
    main.cpp:355:21: error: use of undeclared identifier 'omp_get_num_threads'
    """

    caused by the error that for some reason, the header file omp.h cannot be found:
    """
    main.cpp:10:10: error: 'omp.h' file not found
    """

    However, I can run the program without any errors and the output does not seem exhibit undefined behavior. Compiling from the command line works as well e.g. by
    """
    g++ main.cpp -fopenmp -std=c++20
    """

    What could be the root cause for this problem?

    1 Reply Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher moved this topic from Qt 6 on
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Move add_executable line after you find_package. Not sure if it will help, but it might.

      (Z(:^

      S 1 Reply Last reply
      0
      • cristian-adamC Online
        cristian-adamC Online
        cristian-adam
        wrote on last edited by
        #3

        Which version of Qt Creator are you using? clangd needs to be build with the openmp module enabled.

        You should check if you have qtcreator/libexec/qtcreator/clang/lib/clang/17/include/omp.h in your Qt Creator installation.

        The official https://download.qt.io/official_releases/qtcreator/13.0/ Qt Creator binaries all have right clangd and omp.h header.

        1 Reply Last reply
        0
        • sierdzioS sierdzio

          Move add_executable line after you find_package. Not sure if it will help, but it might.

          S Offline
          S Offline
          Sampo Paukkonen
          wrote on last edited by
          #4

          @sierdzio

          For future reference, this did not solve the issue.

          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 Extensions
          • Unsolved