User forums => Using Code::Blocks => Topic started by: musvn84 on January 21, 2020, 01:01:00 am

Title: Issue is cannot find -lgomp
Post by: musvn84 on January 21, 2020, 01:01:00 am
Dear all,

I have just downloaded the file codeblocks-17.12mingw-setup.exe and installed it on my Windows 7. The file is installed very well on my computer. Moreover, I added some properties as follows:
1) Compiler settings -> Other compiler options -> -fopenmp
2) Linker settings -> Other linker options -> -lgomp -pthread

Everything is fine now. But I try to compile the following file:
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>

int main (int argc, char *argv[])
int nthreads, tid;

#pragma omp parallel private(nthreads, tid)

  tid = omp_get_thread_num();
  printf("Hello World from thread = %d\n", tid);

  if (tid == 0)
    nthreads = omp_get_num_threads();
    printf("Number of threads = %d\n", nthreads);



My issue is cannot find -lgomp.

Could someone please help me to fix this problem?
many thanks
Title: Re: Issue is cannot find -lgomp
Post by: stahta01 on January 21, 2020, 05:41:06 am
From compiler README-gcc-tdm.txt
In order to correctly compile code that utilizes OpenMP/libGOMP, you need to add
the "-fopenmp" option at compile time AND link time. By default, this will link
the static version of winpthreads to your program, and you should not need to
distribute any additional DLLs with your program. If you plan to distribute a
program that relies on OpenMP and winpthreads, be sure to understand and comply
with the terms of winpthreads' license (see COPYING.winpthreads.txt).

Tim S.
Title: Re: Issue is cannot find -lgomp
Post by: BlueHazzard on January 22, 2020, 10:02:44 am
To add compiler options:
Project->Build options->Select your project name on the left->Compiler options->other compiler options

To add linker options
Project->Build options->Slect your project name on the left->Linker->other linker options

If you have a problem building your project, please read and follow this link:

if your report does not follow the above link we will not be able to help you...