# OpenMP omp_get_num_procs

This topic is 2501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
Are you sure you are compiling with "-fopenmp"?

##### Share on other sites

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.

That solved the case.

##### Share on other sites

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.

• 18
• 11
• 16
• 9
• 49
• ### Forum Statistics

• Total Topics
631395
• Total Posts
2999780
×