Sign in to follow this  
Misery

OpenMP omp_get_num_procs

Recommended Posts

Misery    354
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
Misery    354
[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
Sneftel    1788
[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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this