Problems Undefined reference

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
focus
Posts: 77
Joined: Wed, 2005-03-16, 20:29
Location: Catalonia

Problems Undefined reference

#1 Post by focus »

Hello! I'm a new user of dcmtk libraries. I have some linkings problems when I try to compile a simple code. This code makes an echo to the pacs. The error is the next


: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_empty_rep_storage'
/usr/lib/dcmtk/libdcmdata.a(dcsequen.o)(.text+0xd3a): more undefined references to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_empty_rep_storage' follow


I'm using Fedora 3, but A friend have tried to compile the same code with a mandrake 10, and the code works, the compile doesn't gets any error. I believe that the problem is the Fedora, there is any solution? Or the solution is that I have to install another libraries.

Thanks for your help.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1445
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#2 Post by Marco Eichelberg »

looks like you need to link against some standard libary that is not automatically included in the linker call by the compiler. Try something like adding -lstdc++ to the LIBS= line in config/Makefile.def (this file is created during the configure run).

focus
Posts: 77
Joined: Wed, 2005-03-16, 20:29
Location: Catalonia

#3 Post by focus »

I have tryed this, I have put in the makefile the libraries lstdc++ and lc, but the problem is still continuing. I have tryed in the mandrake and I have observed that in the Makefile, the mandrake doesn't put the lstdc++ libraries too. I believe that the problem is another thing

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1445
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#4 Post by Marco Eichelberg »

You won't probably like this, but they may be many reasons for the error messages above, and it will not be possible to support you unless the error can somehow be reproduced. The error message is clear enough, a function of the stdio library that is used by your code cannot be resolved during the link process. You are either not linking all required libraries or you are linking wrong versions of these libraries. In any case, this is a most likely a problem with the installation of your C++ compiler, not with DCMTK.

newbould
Posts: 3
Joined: Wed, 2005-01-05, 23:52

Same problem

#5 Post by newbould »

Any library gurus out there want to tackle this one?
I seem to have the same problem:

Code: Select all

g++ -o IRfispfit newfit.o qld.o cfsqp.o -L/usr/local/dicom/lib -lool -lgsl \
-lgslcblas -ldcmdata -lofstd -lpthread -lz -lstdc++
/usr/local/dicom/lib/libdcmdata.a(dcitem.o): In function `char* std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_construct<char*>(char*, char*, std::allocator<char> const&, std::forward_iterator_tag)':
dcitem.cc:(.gnu.linkonce.t._ZNSs12_S_constructIPcEES0_T_S1_RKSaIcESt20forward_iterator_tag+0x19): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_empty_rep_storage'
dcitem.cc:(.gnu.linkonce.t._ZNSs12_S_constructIPcEES0_T_S1_RKSaIcESt20forward_iterator_tag+0x1e): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_empty_rep_storage'
dcitem.cc:(.gnu.linkonce.t._ZNSs12_S_constructIPcEES0_T_S1_RKSaIcESt20forward_iterator_tag+0x48): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_create(unsigned int, std::allocator<char> const&)'
collect2: ld returned 1 exit status
make: *** [IRfispfit] Error 1
This is gcc 4.0.2. Remarking out the dcmtk stuffs gets me a file that builds without any warnings/errors.

Also, if I statically link in the stdc++ library, all is well:
g++ -static -o IRfispfit newfit.o qld.o cfsqp.o /usr/lib/libstdc++.a -L/usr/local/dicom/lib -lool -lgsl -lgslcblas -ldcmdata -lofstd -lpthread -lz

I am mystified as to why static works, but shared libs doesnt, but I'll keep poking....

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1445
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#6 Post by Marco Eichelberg »

Do you possibly have multiple gcc versions installed, or some older versions of libstdc++ from previous gcc installations as a leftover in /usr/lib, causing gcc to use the up-to-date version of the static library but an outdated version of the dynamic library (i.e. shared object)?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest