Including OpenCV libraries breaks OpenACC code

I have a C++ program that uses OpenACC to parallelize some parts of its code, but also needs to use some OpenCV functions. The default code with OpenACC and without OpenCV works well (i.e. I can see a large speedup and 100% GPU utilization), but unfortunately when I try to use OpenCV and run the code again, the only output I get in the terminal is the following strange message:

libgomp: TODO

and the program stops after printing this single statement. After additional tests to try and find out which OpenCV functions cause the code to print out the above message, it seems that simply linking the OpenCV libraries to my program executable, and not even calling any OpenCV functions causes the code to break.

Here is a working OpenACC example that I copied from gcc - C++ Matrix Multiply Slower OpenACC - Stack Overflow, which I’ve used to compare with and without OpenCV:

#include “stdlib.h”
#include “stdio.h”
#include “cassert”
#include “chrono”

#define ACC_TYPE parallel
#define ACC_TYPE kernels

double *A, *B, *C;

int main() {
long long N = 500;

A = new double[N * N];
B = new double[N * N];
C = new double[N * N];


for (int i = 0; i < N; i++) {

    for (int j = 0; j < N; j++) {
        A[i * N + j] = rand();
        B[i * N + j] = rand();

#pragma acc data copyin(A[:N*N],B[:N*N]) copyout(C[:N*N])
for (int x = 0; x < 10; x++) {
    auto start_time = std::chrono::high_resolution_clock::now();
    #pragma acc ACC_TYPE
        #pragma acc loop independent
        for (int i = 0; i < N; i++) {
            #pragma acc loop independent
            for (int j = 0; j < N; j++) {
                double total = 0;
                #pragma acc loop independent reduction (+: total)
                for (int k = 0; k < N; k++) {
                    total += A[i * N + j] * B[k * N + j];
                C[i * N + j] = total;
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> duration = end_time - start_time;
    printf("%f seconds\n", duration.count());
return 0;


and in my CMakeLists.txt file I’ve included the OpenCV libraries as follows:

find_package(OpenCV REQUIRED)

add_executable(main src/main.cpp)
target_link_libraries(main ${OpenCV_LIBS})
set(CMAKE_CXX_FLAGS “-acc”)

If I run the above code without OpenCV, the program runs and prints out the time required to compute matrix-matrix multiplication. However, if I link the OpenCV libraries to the program, as is done in the above CMake example, the program simply prints out libgomp: TODO and then stops running.

Has anyone else experienced such an odd error? In case this may be useful, I’m running Ubuntu 18.04 with OpenCV 3.2. Any help would be much appreciated, thanks.

P.S. The forum seems to not be printing/formatting the code correctly in some places, so please give me a shout if you try running the code and it doesn’t work, it may just be that the forum’s formatted code left a few things out.

update everything. absolutely do not use opencv 3.2. that is very outdated.

google says libgomp is to blame. hopefully they’ve fixed their foul-up and you can get a version of their library that doesn’t do that anymore.

I am also experiencing the same problem. I use OpenCV to read an image, process it, and then work with the raw data using OpenACC.

My OpenCV version is 4.6.0 and I use NVIDIA HPC SDK 22.5, which includes OpenACC and the corresponding compiler (nvc++). When I run my program, it prints “libgomp: TODO”, returning code 1. Does anyone know any workaround?

where does that libgomp: TODO string come from? I can’t find it in OpenCV source. it seems related to GNU OpenMP.

I can find it mentioned on the nvidia forums, where no reference to OpenCV is made.

perhaps you should seek NVIDIA-specific help.


In my opinion, you can try to install opencv with nvc++ or pgc++ compiler.

Or you can module load the $compiler_environment.