Skip to main content
GameDev.net gamedev.net
🔒 Locked

OpenMP omp_get_num_procs

Started by Misery Aug 15, 2011 at 8:51 AM 2 replies 6.4k views
Original Post
Misery
Misery
Hi there,

I have a strange problem. I'm getting on with OpenMP, however I get error messages when I am trying to use omp functions:


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

using namespace std;

int main()
{
std::cout<<omp_get_num_procs()<<std::endl;

std::cout << "Finished" <<std::endl;
return 0;
}



So the code isn't especially complicated but I get an error:

undefined reference to `omp_get_num_procs

I have read OpenMP manual and there's not mentioned that omp requires any additional libs or dlls.
So what is wrong?

I am using GCC here.

Regards,
Misery
Misery
Misery

Are you sure you are compiling with "-fopenmp"?


Yes. In fact when using GCC on Linux (Debian, Ubuntu) or MinGW with Code::Blocks, one has to link libraries manually.
I mean, add additional libs to linker directories.

That solved the case.
Sneftel
Sneftel

So what is wrong?

You need to include the OpenMP library.

I have read OpenMP manual and there's not mentioned that omp requires any additional libs or dlls.
[/quote]
That's because the manual is about the OpenMP standard, not the particular OpenMP implementation you're using.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.