Sorry for the previous message, after some google search I have found that with
nm --print-file-name /usr/lib/* 2> /dev/null | grep sem_init
one is able to find what library is needed for a given fct. name.
---------- Forwarded message ----------
From: Bogdan Cristea
Date: Thu, Apr 24, 2008 at 11:26 AM
Subject: Unable to compile program using POSIX semaphores
To: programming@opensuse.org
Cc: opensuse@opensuse.org
I use semaphores in a C++ class, but I get errors when linking my
programs. Below is the output when compiling and linking the programs.
It seems that the functions related to semaphores are not found by the
linker. Could you advise please?
g++ -c -ansi -pedantic -Werror -Wall -O3 -W -Wconversion -Wshadow
-Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -fshort-enums
-fno-common use_cb.cpp -o use_cb.o
g++ -c -ansi -pedantic -Werror -Wall -O3 -W -Wconversion -Wshadow
-Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -fshort-enums
-fno-common CB.cpp -o CB.o
g++ use_cb.o CB.o -o use_cb
CB.o: In function `CB::reset()':
CB.cpp:(.text+0x1e5): undefined reference to `sem_destroy'
CB.cpp:(.text+0x200): undefined reference to `sem_init'
CB.o: In function `CB::create(int const&)':
CB.cpp:(.text+0x266): undefined reference to `sem_init'
CB.o: In function `CB::write(char const*, int const&)':
CB.cpp:(.text+0x35f): undefined reference to `sem_post'
CB.o: In function `CB::read(char*, int const&)':
CB.cpp:(.text+0x3e7): undefined reference to `sem_wait'
CB.o: In function `CB::clear()':
CB.cpp:(.text+0x565): undefined reference to `sem_destroy'
CB.cpp:(.text+0x580): undefined reference to `sem_init'
CB.o: In function `CB::release()':
CB.cpp:(.text+0x5dc): undefined reference to `sem_destroy'
CB.cpp:(.text+0x5f7): undefined reference to `sem_init'
CB.cpp:(.text+0x62f): undefined reference to `sem_destroy'
collect2: ld returned 1 exit status
make: *** [use_cb] Error 1
--
Bogdan Cristea
--
Bogdan Cristea
--
To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse+help@opensuse.org