Reputation: 21
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 ).
Upvotes: 1
Views: 2923
Reputation: 1
As Bob said,the reason is there are two installations of MinGW.After I uninstall the former installed version,cFree works.
Upvotes: 0
Reputation: 153
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.
Upvotes: 3