LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-07-2007, 05:31 PM   #1
Mash
LQ Newbie
 
Registered: Dec 2006
Posts: 16

Rep: Reputation: 0
Linking OpenMP


Hi there,

I am trying to write a program using openMP but i am getting the following message when compiling:

/tmp/ccpvkTQn.o: In function `main':
parallel.c.text+0x12): undefined reference to `omp_get_thread_num'
parallel.c.text+0x33): undefined reference to `omp_get_num_threads'
collect2: ld returned 1 exit status

I am guessing that I am failing to link to the openMP libraries. How exactly do I do this?
Should it be something like:

gcc -lomp prog.c -o prog

Any help would be awesome!

Thanx

Mash
 
Old 03-09-2007, 05:53 AM   #2
KenJackson
Member
 
Registered: Jul 2006
Location: Maryland, USA
Distribution: Fedora and others
Posts: 757

Rep: Reputation: 145Reputation: 145
I don't know what 'openMP' is, but your own suggestion looks pretty good.

Using -lomp means you are linking to library files named libomp.so and libomp.la (or libomp.a for static), probably in /usr/lib. If you can't find those files, then either you have the wrong name or openMP isn't installed.

Note that many packages have a separate package for development. So a package named package would have package-devel which must be installed separately in order to do development.
 
Old 07-28-2007, 02:44 PM   #3
Brun007
LQ Newbie
 
Registered: Jul 2003
Location: Manaus, Brazil
Distribution: Ubuntu Feisty
Posts: 4

Rep: Reputation: 0
Gomp

Quote:
Originally Posted by Mash
Hi there,

I am trying to write a program using openMP but i am getting the following message when compiling:

/tmp/ccpvkTQn.o: In function `main':
parallel.c.text+0x12): undefined reference to `omp_get_thread_num'
parallel.c.text+0x33): undefined reference to `omp_get_num_threads'
collect2: ld returned 1 exit status

I am guessing that I am failing to link to the openMP libraries. How exactly do I do this?
Should it be something like:

gcc -lomp prog.c -o prog

Any help would be awesome!

Thanx

Mash
Hi Mash,
I was having the same problem too, 'til I found that the right library to use is libgomp.so.1. So, in order to compile it you have to use, e.g: "gcc -lgomp helloworld.c -o helloworld"

[]s
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
openmp in suse 10.2 ezhaar Programming 2 02-18-2007 12:37 PM
linking? kalleanka Programming 4 11-09-2006 09:16 AM
Problem in using both load time linking and runtime linking durgaprasad_j Linux - General 0 08-01-2006 03:49 AM
C++ linking? ugenn Programming 5 05-14-2002 01:33 AM
openMP? distributed shared memory? Hano Linux - General 0 05-11-2002 11:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration