Can't compile...pthread errror

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

Can't compile...pthread errror

#1 Post by martinrame »

Hi, I downloaded 3.6.0 sources and tried to compile on Ubuntu 12.04 x86_64, then ./configure && make clean all, but I've got this:

Code: Select all

a - oflist.o
a - ofstring.o
a - ofcmdln.o
a - ofconapp.o
a - offname.o
a - ofconsol.o
a - ofthread.o
a - ofcond.o
a - ofstd.o
a - ofcrc32.o
a - ofdate.o
a - oftime.o
a - ofdatime.o
a - ofconfig.o
ranlib libofstd.a
make[2]: se sale del directorio «/home/leonardo/Desarrollo/dcmtk/dcmtk-3.6.0-shared/ofstd/libsrc»
(cd tests && make ARCH="" all)
make[2]: se ingresa al directorio «/home/leonardo/Desarrollo/dcmtk/dcmtk-3.6.0-shared/ofstd/tests»
c++	-DHAVE_CONFIG_H -DUSE_NULL_SAFE_OFSTRING  -DNDEBUG  -c -I. -I. -I../include -I../../config/include -I../include  \
		 -O -I/usr/include/libxml2 -D_REENTRANT -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L -Wall  tststack.cc
c++ -O -I/usr/include/libxml2 -D_REENTRANT -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L -Wall   -L../libsrc -o tststack tststack.o -lofstd -lrt -lpthread -lnsl 
../libsrc/libofstd.so: undefined reference to `sem_init'
../libsrc/libofstd.so: undefined reference to `pthread_mutex_trylock'
../libsrc/libofstd.so: undefined reference to `pthread_rwlock_trywrlock'
../libsrc/libofstd.so: undefined reference to `pthread_key_create'
../libsrc/libofstd.so: undefined reference to `pthread_rwlock_rdlock'
../libsrc/libofstd.so: undefined reference to `pthread_rwlock_tryrdlock'
../libsrc/libofstd.so: undefined reference to `sem_destroy'
../libsrc/libofstd.so: undefined reference to `pthread_getspecific'
../libsrc/libofstd.so: undefined reference to `pthread_rwlock_wrlock'
../libsrc/libofstd.so: undefined reference to `pthread_create'
../libsrc/libofstd.so: undefined reference to `pthread_rwlock_destroy'
../libsrc/libofstd.so: undefined reference to `pthread_rwlock_init'
../libsrc/libofstd.so: undefined reference to `pthread_rwlock_unlock'
../libsrc/libofstd.so: undefined reference to `sem_post'
../libsrc/libofstd.so: undefined reference to `sem_trywait'
../libsrc/libofstd.so: undefined reference to `pthread_setspecific'
../libsrc/libofstd.so: undefined reference to `sem_wait'
../libsrc/libofstd.so: undefined reference to `pthread_join'
collect2: ld devolvió el estado de salida 1
make[2]: *** [tststack] Error 1
My g++ version is this:

Code: Select all

g++ --version
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
What I'm missing?.

martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

Re: Can't compile...pthread errror

#2 Post by martinrame »

I've found the problem.

The original 3.6.0 code, in config/Makefile.def is this:

Code: Select all

LIBS = -lrt -lpthread -lnsl
Aparently something was updated in my machine, now I have to replace the above by this:

Code: Select all

LIBS = -lpthread -lrt -lnsl
The fix was switching -lrt with -lpthread.

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Can't compile...pthread errror

#3 Post by J. Riesmeier »

Does the current DCMTK snapshot compile out of the box?

I just tried it on my Linux machine ("gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2"), and it works with the original library order.

martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

Re: Can't compile...pthread errror

#4 Post by martinrame »

Today I've got the same error using the release 3.6.0 downloaded from ftp://dicom.offis.de/pub/dicom/offis/so ... 6.0.tar.gz

The steps ar this:

Code: Select all

./configure
make # here there are the errors
Edit the config/Makefile.def and switch -lrt with -lpthread

Code: Select all

make 
After the 2nd make everything compiles as expected.

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Can't compile...pthread errror

#5 Post by J. Riesmeier »

And what about the current snapshot?

martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

Re: Can't compile...pthread errror

#6 Post by martinrame »

I've tested with dcmtk-3.6.1_20131114 and I get the same error if I use this config/Makefile.def (only the # ARCH section):

Code: Select all

# ARCH =

CC = gcc
CFLAGS = -fPIC -O2 -I/usr/include/libxml2 -D_REENTRANT -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L -Wall 
CXX = c++
CXXFLAGS = -fPIC -O2 -I/usr/include/libxml2 -D_REENTRANT -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L -Wall 
CPPFLAGS = 
LDFLAGS = 
RANLIB = :
AR = gcc
ARFLAGS = -shared -o
LIBS = -lrt -lpthread -lnsl 
MATHLIBS = -lm
OPENSSLLIBS = -ldl
TIFFLIBS = 
PNGLIBS = 
ZLIBLIBS = -lz
XMLLIBS = 
TCPWRAPPERLIBS = 
SNDFILELIBS = 
ICONVLIBS = 
LIBEXT = so
BINEXT = 
STRIP = strip
I need to do these changes because I have to compile a shared library.

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Can't compile...pthread errror

#7 Post by J. Riesmeier »

I need to do these changes because I have to compile a shared library.
Officially, building shared libraries with GNU autoconf (aka configure) is not supported by the DCMTK, i.e. you have to adjust the compiler/linker flags as needed (and as you did). Alternatively, you could use CMake (also on Unix) with the latest Snapshot and CMake option BUILD_SHARED_LIBS enabled.

martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

Re: Can't compile...pthread errror

#8 Post by martinrame »

Thanks Jörg, I'll take a look at CMAKE.

martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

Re: Can't compile...pthread errror

#9 Post by martinrame »

Hi Jörg, I can confirm CMake allowed me to compile the shared libraries without any issue.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Baidu [Spider], Bing [Bot], Google [Bot] and 1 guest