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. Qt Creator 4.14.0: cmake project with openmp: omp.h not found
Forum Updated to NodeBB v4.3 + New Features

Qt Creator 4.14.0: cmake project with openmp: omp.h not found

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
qtcreator
4 Posts 2 Posters 2.0k 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.
  • A Offline
    A Offline
    alex9009
    wrote on last edited by
    #1

    Hello.

    I have a problem with Qt Creator 4.14.0 on Ubuntu 20.04 with CMake 3.19. When I open a CMake project in Qt Creator that uses OpenMP, Qt Creator editor cannot find omp.h header file, and, therefore, also complains about OpenMP library functions in my code. I'm using default GCC from Ubuntu 20.04 repos. However, it can still build this project without any problems - so the issue is limited only to editing.

    Below is a sample project to reproduce this issue. Can anyone please suggest a fix for this problem? Is this a bug in Qt Creator or is there a problem in my CMakeLists.txt?

    CMakeLists.txt

    cmake_minimum_required(VERSION 3.19)
    
    project(test)
    
    # OpenMP
    find_package(OpenMP REQUIRED COMPONENTS C)
    message(STATUS "OpenMP_C_FLAGS: ${OpenMP_C_FLAGS}")
    message(STATUS "OpenMP_C_LIBRARIES: ${OpenMP_C_LIBRARIES}")
    message(STATUS "OpenMP_C_INCLUDE_DIRS: ${OpenMP_C_INCLUDE_DIRS}")
    
    add_executable(test test.c)
    target_include_directories(test PRIVATE ${OpenMP_C_INCLUDE_DIRS})
    target_link_libraries(test ${OpenMP_C_LIBRARIES})
    target_compile_options(test PRIVATE ${OpenMP_C_FLAGS})
    

    test.c

    #include <omp.h>
    #include <stdio.h>
    
    int main(){
    #pragma omp parallel
      {
        printf("Thread %i from %i\n", omp_get_thread_num(), omp_get_num_threads());
      }
    }
    
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @alex9009 said in Qt Creator 4.14.0: cmake project with openmp: omp.h not found:

      message(STATUS "OpenMP_C_INCLUDE_DIRS: ${OpenMP_C_INCLUDE_DIRS}")

      So is omp.h in the directory?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      A 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @alex9009 said in Qt Creator 4.14.0: cmake project with openmp: omp.h not found:

        message(STATUS "OpenMP_C_INCLUDE_DIRS: ${OpenMP_C_INCLUDE_DIRS}")

        So is omp.h in the directory?

        A Offline
        A Offline
        alex9009
        wrote on last edited by
        #3

        @Christian-Ehrlicher "OpenMP_C_INCLUDE_DIRS" variable is empty, since OpenMP on GCC on Linux doesn't require any additional header search paths. omp.h is bundled with GCC, it is located in the system "/usr/lib/gcc/x86_64-linux-gnu/9/include/" directory. Qt Creator knows where omp.h is - I can open it in editor by right clicking on "#include <omp.h>" and selecting "Follow symbol under cursor". So it is weird that the editor complains "test.c:1:10: error: 'omp.h' file not found".

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alex9009
          wrote on last edited by
          #4

          There is also the following pop-up when opening test.c in the sample project:

          Warning: The code model could not parse an included file, which might lead to incorrect code completion and highlighting, for example.
          stdio.h:33:10: fatal error: 'stddef.h' file not found
          test.c:1:1: note: in file included from /home/user/CODE/test/test.c:1:
          test.c:2:10: note: in file included from /home/user/CODE/test/test.c:2:

          stddef.h is in the same directory as omp.h.

          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