How do I find out which library contains what ?

How do I find out which library contains what ?

Post by Mike » Fri, 22 Oct 2004 18:55:38



A bit off topic perhaps but how do I find out which library contains
which routines.

I've got these errors and I can't track down which libraries I should be
linking against. It's mostly semaphores and mutex threads etc


-lccext2
telemetry.o(.text+0x81): In function `main':
: undefined reference to `stdscr'
telemetry.o(.text+0x86): In function `main':
: undefined reference to `wgetch'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_yield'
/usr/local/lib/libccgnu2.so: undefined reference to `dlerror'
/usr/local/lib/libccext2.so: undefined reference to `deflate'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_create'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_getspecific'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_rwlock_rdlock'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_rwlock_init'
/usr/local/lib/libccext2.so: undefined reference to `inflate'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_key_delete'
/usr/local/lib/libccgnu2.so: undefined reference to `_pthread_cleanup_pop'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_cancel'
/usr/local/lib/libccgnu2.so: undefined reference to
`pthread_mutexattr_destroy'
/usr/local/lib/libccgnu2.so: undefined reference to `sem_destroy'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_rwlock_destroy'
/usr/local/lib/libccgnu2.so: undefined reference to `sem_wait'
/usr/local/lib/libccgnu2.so: undefined reference to `sem_post'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_testcancel'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_rwlock_unlock'
/usr/local/lib/libccgnu2.so: undefined reference to `dlclose'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_detach'
/usr/local/lib/libccext2.so: undefined reference to `inflateInit_'
/usr/local/lib/libccext2.so: undefined reference to `deflateInit_'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_key_create'
/usr/local/lib/libccgnu2.so: undefined reference to `sem_init'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_kill'
/usr/local/lib/libccgnu2.so: undefined reference to
`pthread_attr_setstacksize'
/usr/local/lib/libccgnu2.so: undefined reference to `dlopen'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_rwlock_wrlock'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_sigmask'
/usr/local/lib/libccgnu2.so: undefined reference to
`pthread_rwlockattr_init'
/usr/local/lib/libccgnu2.so: undefined reference to `sem_trywait'
/usr/local/lib/libccgnu2.so: undefined reference to `dlsym'
/usr/local/lib/libccgnu2.so: undefined reference to
`pthread_mutexattr_settype'
/usr/local/lib/libccgnu2.so: undefined reference to
`pthread_rwlock_trywrlock'
/usr/local/lib/libccgnu2.so: undefined reference to
`pthread_rwlock_tryrdlock'
/usr/local/lib/libccgnu2.so: undefined reference to `_pthread_cleanup_push'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_mutexattr_init'
/usr/local/lib/libccgnu2.so: undefined reference to `sem_getvalue'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_mutex_trylock'
/usr/local/lib/libccext2.so: undefined reference to `infla*d'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_join'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_cond_timedwait'
/usr/local/lib/libccext2.so: undefined reference to `defla*d'
/usr/local/lib/libccgnu2.so: undefined reference to `pthread_setspecific'
collect2: ld returned 1 exit status

 
 
 

How do I find out which library contains what ?

Post by Mike » Fri, 22 Oct 2004 19:46:23



> A bit off topic perhaps but how do I find out which library contains
> which routines.

Panic over. It's something like...


grep sem_init

 
 
 

How do I find out which library contains what ?

Post by Paul Pluzhniko » Fri, 22 Oct 2004 23:30:29



> I've got these errors and I can't track down which libraries I should
> be linking against. It's mostly semaphores and mutex threads etc

You've already found that you need '-lpthread'

Quote:> $ g++ -Wall -o telemetry telemetry.o -lccgnu2 -lccext2

Note however, that there is more to compiling multithreaded programs
then simply adding the missing -lpthread.

On Linux, you should be compiling and linking such programs with
'-pthread' flag, on Solaris with '-pthreads'. This will make gcc
"do the right thing". On other platforms you may have to add
-D_REENTRANT, -D_THREAD_SAFE, or something else.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.