Mailinglist Archive: opensuse (2430 mails)

< Previous Next >
[opensuse] Unable to compile program using POSIX semaphores - solved
  • From: "Bogdan Cristea" <cristeab@xxxxxxxxx>
  • Date: Thu, 24 Apr 2008 11:55:52 +0300
  • Message-id: <e7b7bbdc0804240155t5e755bcdmd4fddb78d85fc06@xxxxxxxxxxxxxx>
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 <cristeab@xxxxxxxxx>
Date: Thu, Apr 24, 2008 at 11:26 AM
Subject: Unable to compile program using POSIX semaphores
To: programming@xxxxxxxxxxxx
Cc: opensuse@xxxxxxxxxxxx


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@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
This Thread
Follow Ups