1

I'm trying to run this simple OpenMP example :

#include <iostream>
#include <omp.h>

using namespace std;

int main()
{
    switch(_OPENMP) {
    case 200805:
        cout << "OpenMP version 3.0 has macro value of 200805" << endl;
        break;
    case 200505:
        cout << "OpenMP version 2.5 has macro value of 200505" << endl;
        break;
    default:
        cout << "Unrecognized OpenMP version of " << _OPENMP << endl;
        break;
    }
    return 0;
}

I get two undefined reference to errors :

c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../crt2.o:(.text+0x1ee): undefined reference to `_CRT_fenv'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../crt2.o:(.text+0x1fb): undefined reference to `_setargv'
collect2.exe: error: ld returned 1 exit status

I already added libgomp-1.dll to link librairies and -fopenmp to other compiler options ( I'm working with code::blocks by the way ).

Stoufa
  • 23
  • 7

1 Answers1

3

I know this is old, but I had the same errors and found this post in my search for an answer, so I suspect I may be able to help someone else with this problem.

I suspect the problem lies in having two installations of MinGW. Did you install the full distribution of Code::Blocks, including MinGw?

The errors reference "c:/mingw/..." I am guessing that you did a separate installation of MinGW, which created that tree. If you let Code::Blocks install it, too, it probably put it in "some_path/CodeBlocks/MinGW/."

If that is the case (as it was for me), in Code::Blocks, go to Settings->Compiler... and in the window that opens, open the "Toolchain executables" tab and change the path for your MinGW executables to be the insatllation path created by Code::Blocks. enter image description here

Bob
  • 143
  • 6
  • 1
    Hey @Bob, thanks for posting. umm, I don't remember, it has been some time since the last time I've used Windows, I used it during university (wasn't my choice), I'm a free man now, however, I hope that this thread will help someone facing the same issue, thanks again. – Stoufa Feb 13 '20 at 18:16
  • 1
    "I suspect the problem lies in having two installations of MinGW." - This was exactly the problem in my case. Thank you! – smmehrab Jan 29 '21 at 14:11