the first program

General OpenMP discussion

the first program

Postby shubham » Sun Dec 14, 2008 5:51 am

i compiled the very same program that is given on the OpenMP website with tdm-mingw-1.812.0-f1 compiler that to my surprise i got these many errors and warnings

C:\>gcc -fopenmp op.c
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(parallel.o):parallel.c:(.text+0x
e): undefined reference to `_imp__pthread_getspecific'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(parallel.o):parallel.c:(.text+0x
46): undefined reference to `_imp__pthread_getspecific'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(parallel.o):parallel.c:(.text+0x
5e): undefined reference to `_imp__pthread_getspecific'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(parallel.o):parallel.c:(.text+0x
9e): undefined reference to `_imp__pthread_getspecific'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0xf): unde
fined reference to `_imp__pthread_key_create'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x22): und
efined reference to `_imp__pthread_setspecific'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x34): und
efined reference to `_imp__sem_init'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x55): und
efined reference to `_imp__pthread_setspecific'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x66): und
efined reference to `_imp__sem_init'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x16d): un
defined reference to `_imp__pthread_getspecific'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x1a1): un
defined reference to `_imp__pthread_mutex_destroy'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x1b6): un
defined reference to `_imp__sem_destroy'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x1e1): un
defined reference to `_imp__pthread_getspecific'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x209): un
defined reference to `_imp__pthread_mutex_init'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x268): un
defined reference to `_imp__sem_init'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x2dd): un
defined reference to `_imp__pthread_attr_init'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x2e8): un
defined reference to `_imp__pthread_attr_setdetachstate'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x2f9): un
defined reference to `_imp__pthread_attr_getstacksize'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x37f): un
defined reference to `_imp__pthread_create'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x3a7): un
defined reference to `_imp__pthread_attr_destroy'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(team.o):team.c:(.text+0x4e5): un
defined reference to `_imp__pthread_attr_setstacksize'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(env.o):env.c:(.text+0x4ad): unde
fined reference to `_imp__pthread_attr_init'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(env.o):env.c:(.text+0x4bc): unde
fined reference to `_imp__pthread_attr_setdetachstate'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(env.o):env.c:(.text+0x562): unde
fined reference to `_imp__pthread_attr_setstacksize'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0x11): undef
ined reference to `_imp__pthread_mutex_lock'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0x20): undef
ined reference to `_imp__pthread_mutex_unlock'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0x56): undef
ined reference to `_imp__sem_post'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0x74): undef
ined reference to `_imp__pthread_mutex_unlock'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0x89): undef
ined reference to `_imp__pthread_mutex_unlock'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0xa5): undef
ined reference to `_imp__pthread_mutex_lock'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0xd0): undef
ined reference to `_imp__sem_post'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0xed): undef
ined reference to `_imp__pthread_mutex_lock'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0x122): unde
fined reference to `_imp__pthread_mutex_lock'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0x12b): unde
fined reference to `_imp__pthread_mutex_unlock'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0x134): unde
fined reference to `_imp__pthread_mutex_destroy'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0x14a): unde
fined reference to `_imp__sem_destroy'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0x174): unde
fined reference to `_imp__pthread_mutex_init'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(bar.o):bar.c:(.text+0x191): unde
fined reference to `_imp__sem_init'
c:/mingw/bin/../lib/gcc/mingw32/4.3.2/libgomp.a(sem.o):sem.c:(.text+0xa): undefi
ned reference to `_imp__sem_wait'
collect2: ld returned 1 exit status

the small code was
Code: Select all
#include <omp.h>
#include <stdio.h>
int main() {
#pragma omp parallel
printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
system("PAUSE");
return 0;
}


what was the problem can anybody please tell me...
thanks a lot
shubham
 

Re: the first program

Postby ejd » Mon Dec 15, 2008 9:12 am

For some reason it looks like the entry points to the pthread library are not being resolved. I have asked someone who really knows the gcc implementation to respond to this. Hopefully he will have some time to help.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: the first program

Postby jakub » Mon Dec 15, 2008 2:40 pm

I'm not familiar with mingw, your best luck would be to contact GCC mingw maintainers: Danny Smith <dannysmith AT users DOT sourceforge DOT net> or
Kai Tietz <kai DOT tietz AT onevision DOT com>. libgomp on mingw just uses the standard <pthread.h> APIs, so probably it depends against which pthread library
libgomp has been compiled/linked against and the same should be used during linking of OpenMP programs. -fopenmp sources in libgomp.spec, which ought to contain
the necessary libraries to link in (e.g. on Linux it contains -lgomp and for -static link also -lrt), plus -fopenmp implies -pthread which links in -lpthread.
jakub
 
Posts: 74
Joined: Fri Oct 26, 2007 3:19 am


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 2 guests