linking problems with posix in cygwin

Brian Pollard b_pollard@trillium.com
Thu Jul 20 11:27:00 GMT 2000


I created the libpthread.a file by:

$(DLLTOOL) --as $(AS) -k --dllname libpthread.dll --output-lib libpthread.a
--def $(srcdir)/libpthread.def

I'm still trying to get the code to compile so I'm not positive it works yet
:)  If you could check it for me that would be great.


I think i figured out that "localtime_r" and "rand_r" are defined in libc.a
and libg.a but when i try those i get the errors:

/usr/lib/libcygwin.a(libccrt0.o)(.bss+0x0):libccrt0.cc: multiple definition
of `_impure_ptr'
/usr/lib/libc.a(impure.o)(.data+0x2ec):impure.c: first defined here
collect2: ld returned 1 exit status

any ideas?

thank you

Brian

-----Original Message-----
From: Chris Faylor [ mailto:cgf@cygnus.com ]
Sent: Thursday, July 20, 2000 11:11 AM
To: 'cygwin@sourceware.cygnus.com'
Cc: b_pollard@trillium.com
Subject: Re: linking problems with posix in cygwin


On Thu, Jul 20, 2000 at 10:42:46AM -0700, Brian Pollard wrote:
>When trying to link many object files in Cygwin I do not know what library
>to include.  On a sun system it compiles with -lposix4.
>
>This is the line:
>gcc -o mt_acc ./ss_gen.o  ./ss_task.o  ./ss_drvr.o  ./ss_timer.o
./ss_mem.o
>./ss_strm.o  ./ss_msg.o  ./ss_queue.o  ./ss_pack.o  ./ss_rtr.o  ./ss_acc.o
>./cm_mem.o  ./cm_bdy5.o  ./mt_ss.o  ./mt_id.o -lpthread -lposix4
>
>I finally got the -lpthread to work but still have the problem with
-lposix4
>library
>
>I get errors of undefined references to "localtime_r" and "rand_r"
>
>Which library should I include from cygwin to compile, or do i need to
>create the library?

There are generally no extra libraries to load in a standard cygwin
distribution;
at least as far as normal C programs are concerned.

I'm not sure where you found a libpthread.a but I doubt if it actually works
with cygwin.  Cygwin has some limited pthread support built in.

If you are getting "undefined" references, this means that the functions are
not
available.  Sorry.

The sources for all of these are available, of course.  In this case you may
be able to find analogous functions in 'newlib', if you want to look into
writing your own versions.  If you do this, I hope you will consider making
the functions available to the developers at newlib@sources.redhat.com so
that
we can all benefit from your work.

-Chris Faylor
-Cygwin Engineering Manager
-Red Hat, Inc.

-------------- next part --------------
; pthread.def
; Last updated: $Date: 1999/09/15 00:56:22 $

; Currently unimplemented functions are commented out.

LIBRARY pthread

EXPORTS
;pthread_atfork
pthread_attr_destroy
pthread_attr_getdetachstate
;pthread_attr_getinheritsched
pthread_attr_getschedparam
;pthread_attr_getschedpolicy
;pthread_attr_getscope
pthread_attr_getstackaddr
pthread_attr_getstacksize
pthread_attr_init
pthread_attr_setdetachstate
;pthread_attr_setinheritsched
pthread_attr_setschedparam
;pthread_attr_setschedpolicy
;pthread_attr_setscope
pthread_attr_setstackaddr
pthread_attr_setstacksize
pthread_cancel
;
; These are implemented as macros
;
;pthread_cleanup_pop
;pthread_cleanup_push
;
pthread_condattr_destroy
pthread_condattr_getpshared
pthread_condattr_init
pthread_condattr_setpshared
pthread_cond_broadcast
pthread_cond_destroy
pthread_cond_init
pthread_cond_signal
pthread_cond_timedwait
pthread_cond_wait
pthread_create
pthread_detach
pthread_equal
pthread_exit
pthread_getschedparam
pthread_getspecific
pthread_join
pthread_key_create
pthread_key_delete
;pthread_kill
pthread_mutexattr_destroy
;pthread_mutexattr_getprioceiling
;pthread_mutexattr_getprotocol
pthread_mutexattr_getpshared
pthread_mutexattr_init
;pthread_mutexattr_setprioceiling
;pthread_mutexattr_setprotocol
pthread_mutexattr_setpshared
pthread_mutexattr_destroy
pthread_mutex_init
pthread_mutex_destroy
pthread_mutex_lock
pthread_mutex_trylock
pthread_mutex_unlock
pthread_once
pthread_self
pthread_setcancelstate
pthread_setcanceltype
pthread_setschedparam
pthread_setspecific
;pthread_sigmask
pthread_testcancel
;
; POSIX 1.b
;
sched_get_priority_min
sched_get_priority_max
sched_yield
sem_init
sem_destroy
sem_trywait
sem_wait
sem_post
sem_open
sem_close
sem_unlink
sem_getvalue
;
; Read/Write Locks
;
pthread_rwlock_init
pthread_rwlock_destroy
pthread_rwlock_tryrdlock
pthread_rwlock_trywrlock
pthread_rwlock_rdlock
pthread_rwlock_wrlock
pthread_rwlock_unlock
;
; Non-portable but useful
;
pthread_mutexattr_setforcecs_np
pthreadCancelableWait
pthreadCancelableTimedWait
;
; Needed if !defined(_MSC_VER) && !defined(__cplusplus)
;
pthread_push_cleanup
pthread_pop_cleanup


More information about the Cygwin mailing list