Author Topic: Issue is cannot find -lgomp  (Read 1428 times)

Offline musvn84

  • Single posting newcomer
  • *
  • Posts: 1
Issue is cannot find -lgomp
« 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

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7130
    • My Best Post
Re: Issue is cannot find -lgomp
« Reply #1 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.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
When in doubt, read the CB WiKi FAQ.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2974
Re: Issue is cannot find -lgomp
« Reply #2 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...