undefined reference for dcmtk libraries

Compilation and installation of DCMTK

Moderator: Moderator Team

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

Re: undefined reference for dcmtk libraries

#16 Post by J. Riesmeier »

Tried snapshot with VS15 and building the example you provided received many errors like:
Seems like you are mixing libraries with different settings for "code generation". If you don't understand what this means, you should probably learn more about your compiler/linker before you start programming. I'm sorry but these are the basics, which are not DCMTK-specific.
Also, compiling dcmtk libraries received multiple warnings.
I also installed VS 2015 a couple of days ago (my main platform for development is Linux with gcc). Most (if not all) of the warning are non-critical. We'll get rid of them for the next release.

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

Re: undefined reference for dcmtk libraries

#17 Post by J. Riesmeier »

Should be easy to find but... the linker error is described here: https://msdn.microsoft.com/en-us/en-en/ ... 89284.aspx
RuntimeLibrary
Indicates the version of the C++ Standard Library and C runtime that's used by an app or library.
Code that uses one version of the C++ Standard Library or C runtime is incompatible with code that uses a different version.
For more information, see /MD, /MT, /LD (Use Run-Time Library).

karatystas
Posts: 20
Joined: Fri, 2016-02-19, 08:51

Re: undefined reference for dcmtk libraries

#18 Post by karatystas »

Now I have tried to build the latest snapshot version with Visual Studio Express 2013 for Desktop and got the following warning:
strcloc.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
Is it an important warning which could cause the later failure of using the libraries?

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

Re: undefined reference for dcmtk libraries

#19 Post by J. Riesmeier »

No, as I said the warnings are non-critical (even for VS 2013). Warnings are warnings but no errors. The cited warning just means that the "strcloc.obj" file does not define any symbols (global variables or functions/methods) that are not defined anywhere else. DCMTK is a portable toolkit so it does not only support Windows but also Linux, Mac OS X, FreeBSD, OpenBSD, etc. Some compilers moan about things like that and others do not...

We try to get rid of all warnings for a release (using the supported compilers with default settings) but not necessarily for each and every snapshot (which would not be feasible for the long list of supported platforms (operating systems and compilers)).

Your problem is not compiling (and linking) the DCMTK but linking it with your own program - see my above postings.

karatystas
Posts: 20
Joined: Fri, 2016-02-19, 08:51

Re: undefined reference for dcmtk libraries

#20 Post by karatystas »

Thank you for your kind help J. Riesmeier. Finally I made it work with VS2013. I needed to change my testapp Runtime Library option from Multi-threaded Debug DLL (/MDd) to Multi-threaded Debug (/MTd) in Property Pages. Actually, I don't really understand what is the difference :D Now I have the problem with launching it in Qt creator...

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

Re: undefined reference for dcmtk libraries

#21 Post by J. Riesmeier »

Good to hear that you are on the right track :)

Of course, you can also compile the DCMTK with "Multi-threaded Debug DLL (/MDd)". For doing so, just disable the CMake option DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS and recompile... this will let CMake decided what's "best" for your system.

karatystas
Posts: 20
Joined: Fri, 2016-02-19, 08:51

Re: undefined reference for dcmtk libraries

#22 Post by karatystas »

Now I have tried with Qt creator and I get the following error:
C:\DCMTK\include\dcmtk\ofstd\offile.h:397: error: cannot convert 'bool' to 'FILE* {aka _iobuf*}' in assignment
file_ = _popen(command, modes);
If I open the file offile.h and change line file_ = _popen(command, modes) to file_ = ::popen(command, modes) I do not get this error anymore but then I get the undefined reference error as I mentioned at the begining. Is it OK to change the file like this or there is another problem behind it?

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

Re: undefined reference for dcmtk libraries

#23 Post by J. Riesmeier »

Of course, it is not "OK" (i.e. not the right way) to change the source code. Whether _popen() or ::popen() is used, this is determined during the configuration step (DCMTK's CMake or Autoconf process). Therefore, it is important that DCMTK's "osconfig.h" header file is included first in each and every DCMTK source/header file.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest