Important: Please read the Qt Code of Conduct -

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

  • 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?


    cmake_minimum_required(VERSION 3.19)
    # OpenMP
    find_package(OpenMP REQUIRED COMPONENTS C)
    message(STATUS "OpenMP_C_FLAGS: ${OpenMP_C_FLAGS}")
    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})


    #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());

  • Lifetime Qt Champion

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


    So is omp.h in the directory?

  • @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".

  • 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.

Log in to reply