Sign in to follow this  

OpenMP omp_get_num_procs

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

If you intended to correct an error in the post then please contact us.

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:

[code]
#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;
}

[/code]

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

[code]undefined reference to `omp_get_num_procs[/code]

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 this post


Link to post
Share on other sites
[quote name='japro' timestamp='1313399239' post='4849305']
Are you sure you are compiling with "-fopenmp"?
[/quote]

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.

Share this post


Link to post
Share on other sites
[quote name='Misery' timestamp='1313398274' post='4849300']
So what is wrong?
[/quote]
You need to include the OpenMP library.
[quote]
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.

Share this post


Link to post
Share on other sites
Sign in to follow this