Cmakelist.txt of 3.6.1 missing Platform-specific settings

Compilation and installation of DCMTK

Moderator: Moderator Team

Message
Author
kamil
Posts: 63
Joined: Fri, 2009-04-17, 09:18

Cmakelist.txt of 3.6.1 missing Platform-specific settings

#1 Post by kamil »

I am using 3.6.1 20131114 version.
I found the Cmakelist.txt missing Platform-specific settings which is in 3.6.0 version.
Should I add these settings in Cmakelist.txt by myself?
I want to use MDd for code generation.

I compiled it to 64bit vs11 version in win7.

And I found errors in MTd compiling when using dcmdata.lib in Multi-Byte Character Set:
ClCompile:
1> Source.cpp
1>oflog.lib(winsock.obj) : error LNK2019: unresolved external symbol __imp_WSASocketA referenced in function "__int64 __cdecl dcmtk::log4cplus::helpers::connectSocket(class OFString const &,unsigned short,bool,enum dcmtk::log4cplus::helpers::SocketState &)" (?connectSocket@helpers@log4cplus@dcmtk@@YA_JAEBVOFString@@G_NAEAW4SocketState@123@@Z)
1>oflog.lib(winsock.obj) : error LNK2019: unresolved external symbol __imp_WSAStringToAddressA referenced in function "__int64 __cdecl dcmtk::log4cplus::helpers::connectSocket(class OFString const &,unsigned short,bool,enum dcmtk::log4cplus::helpers::SocketState &)" (?connectSocket@helpers@log4cplus@dcmtk@@YA_JAEBVOFString@@G_NAEAW4SocketState@123@@Z)
1>E:\Projects\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe : fatal error LNK1120: 2 unresolved externals
And found this errors in Unicode Character Set :
Error 1 error C2678: binary '+' : no operator found which takes a left-hand operand of type 'const wchar_t [8]' (or there is no acceptable conversion) E:\Projects\ConsoleApplication1\include\dcmtk\oflog\tracelog.h 59
Error 2 error C2678: binary '+' : no operator found which takes a left-hand operand of type 'const wchar_t [8]' (or there is no acceptable conversion) E:\Projects\ConsoleApplication1\include\dcmtk\oflog\tracelog.h 64
Error 3 error C2665: 'dcmtk::log4cplus::Logger::getInstance' : none of the 2 overloads could convert all the argument types E:\Projects\ConsoleApplication1\include\dcmtk\oflog\logmacro.h 107
Any suggestion? Thanks!

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

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#2 Post by J. Riesmeier »

I am using 3.6.1 20131114 version.
I found the Cmakelist.txt missing Platform-specific settings which is in 3.6.0 version.
Should I add these settings in Cmakelist.txt by myself?
No, you should never modify the CMakeLists.txt files directly, because then your changes get lost with the next update.

Furthermore, I cannot see that anything is missing in the current Snapshot with regards to CMake configuration files. Maybe, you missed the settings in the "dcmtk/CMake" subdirectory?
I want to use MDd for code generation.
Then you should disable the option "DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS" in the CMake user interface...
And I found errors in MTd compiling when using dcmdata.lib in Multi-Byte Character Set:
What do you mean by "using ... in Multi-Byte Character Set"? Are you compiling with UNICODE defined? This is (and, actually, never was) supported by the DCMTK. There's also a section on this in the INSTALL file:

Code: Select all

5. DCMTK does not compile when UNICODE or _UNICODE is defined because the
   VisualStudio compiler then uses the Unicode version instead of the ANSI
   version for all Windows API functions (i.e. type wchar_t instead of char
   for all character string parameters and return values).

kamil
Posts: 63
Joined: Fri, 2009-04-17, 09:18

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#3 Post by kamil »

J. Riesmeier wrote:
Then you should disable the option "DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS" in the CMake user interface...
Hi, thank you for your reply, when I use dcmdata.lib, there is an error:

Code: Select all

1>------ Rebuild All started: Project: ConsoleApplication1, Configuration: Debug x64 ------
1>Build started 2013/12/6 16:10:20.
1>_PrepareForClean:
1>  Deleting file "x64\Debug\ConsoleApplication1.lastbuildstate".
1>InitializeBuildStatus:
1>  Touching "x64\Debug\ConsoleApplication1.unsuccessfulbuild".
1>ClCompile:
1>  Source.cpp
1>oflog.lib(winsock.obj) : error LNK2019: unresolved external symbol __imp_WSASocketA referenced in function "__int64 __cdecl dcmtk::log4cplus::helpers::openSocket(unsigned short,enum dcmtk::log4cplus::helpers::SocketState &)" (?openSocket@helpers@log4cplus@dcmtk@@YA_JGAEAW4SocketState@123@@Z)
1>oflog.lib(winsock.obj) : error LNK2019: unresolved external symbol __imp_WSAStringToAddressA referenced in function "__int64 __cdecl dcmtk::log4cplus::helpers::connectSocket(class OFString const &,unsigned short,bool,enum dcmtk::log4cplus::helpers::SocketState &)" (?connectSocket@helpers@log4cplus@dcmtk@@YA_JAEBVOFString@@G_NAEAW4SocketState@123@@Z)
1>E:\Projects\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe : fatal error LNK1120: 2 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.25
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

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

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#4 Post by J. Riesmeier »

Apparently, the linker error is caused by your own program (and not by any of the DCMTK tools). So I guess that you missed to link a library to your program.
Did you link the standard Windows libraries to your program, which are also linked to all DCMTK tools (i.e. ws2_32, netapi32, wsock32)?

kamil
Posts: 63
Joined: Fri, 2009-04-17, 09:18

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#5 Post by kamil »

J. Riesmeier wrote:Apparently, the linker error is caused by your own program (and not by any of the DCMTK tools). So I guess that you missed to link a library to your program.
Did you link the standard Windows libraries to your program, which are also linked to all DCMTK tools (i.e. ws2_32, netapi32, wsock32)?
After I add ws2_32.lib, link success! Thanks!
Btw, when do you add ws2_32.lib to the link list?(compared to 3.6.0)

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

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#6 Post by J. Riesmeier »

This library was already linked to the apps in DCMTK 3.6.0 (see main CMakeLists.txt file).

rakeshd
Posts: 11
Joined: Wed, 2014-01-15, 08:43
Location: South Korea

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#7 Post by rakeshd »

Hi there,
I am facing the same issue as mentioned in this post.
When I tried the latest snapshot dcmtk-3.6.1_20131114, it gave me nightmare.
There is no issue building dcmtk static libs.
The issue appears when I try to build the apps.
--------------------------------
46>E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/oflog/tracelog.h(59): error C2678: binary '+' : no operator found which takes a left-hand operand of type 'const wchar_t [8]' (or there is no acceptable conversion)
46> E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/ofstd/ofstring.h(867): could be 'OFString operator +(const OFString &,const OFString &)'
46> E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/ofstd/ofstring.h(874): or 'OFString operator +(const char *,const OFString &)'
46> E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/ofstd/ofstring.h(881): or 'OFString operator +(char,const OFString &)'
46> E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/ofstd/ofstring.h(888): or 'OFString operator +(const OFString &,const char *)'
46> E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/ofstd/ofstring.h(895): or 'OFString operator +(const OFString &,char)'
46> while trying to match the argument list '(const wchar_t [8], dcmtk::log4cplus::tstring)'
46>E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/oflog/tracelog.h(64): error C2678: binary '+' : no operator found which takes a left-hand operand of type 'const wchar_t [8]' (or there is no acceptable conversion)
46> E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/ofstd/ofstring.h(867): could be 'OFString operator +(const OFString &,const OFString &)'
46> E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/ofstd/ofstring.h(874): or 'OFString operator +(const char *,const OFString &)'
46> E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/ofstd/ofstring.h(881): or 'OFString operator +(char,const OFString &)'
46> E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/ofstd/ofstring.h(888): or 'OFString operator +(const OFString &,const char *)'
46> E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/ofstd/ofstring.h(895): or 'OFString operator +(const OFString &,char)'
46> while trying to match the argument list '(const wchar_t [8], dcmtk::log4cplus::tstring)'
46>E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/oflog/logmacro.h(107): error C2665: 'dcmtk::log4cplus::Logger::getInstance' : none of the 2 overloads could convert all the argument types
46> E:\SVN_Projects\OpenSource_Repo\Includes\dcmtk/oflog/logger.h(112): could be 'dcmtk::log4cplus::Logger dcmtk::log4cplus::Logger::getInstance(const dcmtk::log4cplus::tstring &)'
46> while trying to match the argument list '(const dcmtk::log4cplus::tchar *)'

--------------------


What I could see is if I revert the oflog module to 3.6.0 version and keep everything else, its fine.

Please give me some pointers. I don't have any clue.

Thanks
Rakesh D

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

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#8 Post by J. Riesmeier »

Did you already try to use the latest development version from the git repository?

Do you try to build the DCMTK (with its apps) or your own application (based on the DCMTK)?

rakeshd
Posts: 11
Joined: Wed, 2014-01-15, 08:43
Location: South Korea

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#9 Post by rakeshd »

Here is one difference i found.

In the app projects setting, I am using "Unicode Character Set" instead of "Multi-Byte Character Set"

But with that the build was okay before and now w/o oflog module as i mentioned.

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

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#10 Post by J. Riesmeier »

From the INSTALL file:

Code: Select all

5. DCMTK does not compile when UNICODE or _UNICODE is defined because the
   VisualStudio compiler then uses the Unicode version instead of the ANSI
   version for all Windows API functions (i.e. type wchar_t instead of char
   for all character string parameters and return values).

rakeshd
Posts: 11
Joined: Wed, 2014-01-15, 08:43
Location: South Korea

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#11 Post by rakeshd »

Thanks.

Will there be any implication of not using UNICODE and program with MBCS or none?, as on VS it is recommended to use UNICODE.

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

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#12 Post by J. Riesmeier »

I don't know (or to be more precise: I don't know much more than what is written in the above cited INSTALL file).
This is not DCMTK-specific but has to do with VS, so I would suggest that you read the documentation of your VS version...

Roadrunner
Posts: 56
Joined: Mon, 2010-06-14, 16:41

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#13 Post by Roadrunner »

same here:
until dcmtk-3.6.1_20131114 everything works really fine with LOG4CPLUS but there are lots of changes
with the last release and the current git repository which makes unable to link against the libs.
All libs are build with /MD which is default since 3.6.0 and they are multi byte characters by default too - in VS2010.

My application is unicode but i've added #undef UNICODE in befor the line #include "dcmtk/oflog/config.h" which
doesn't help.

I'll investigate the problem this week. For me it seems to be a problem with the compiler and concat strings.

Frank

Roadrunner
Posts: 56
Joined: Mon, 2010-06-14, 16:41

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#14 Post by Roadrunner »

Found the solotion:

in the file dcmtkPrepare.cmake are some /MT options which i changed from /MT to /MD and everything works like a charm.

Btw: I don't know why but the cmake gui shows me /MD on the compiler flags while the option was /MT ( in the file). It seems to me if cmake generates the project file it considered the option in the dcmtkPrepare.cmake.
So maybe someone could change this in the git repository (and therefore next release/snapshot) in the next few days.
Thanks

Btw2: I removed the #undef UNICODE pre processor line - so all files (except the cmake file) are original.

Frank

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

Re: Cmakelist.txt of 3.6.1 missing Platform-specific setting

#15 Post by J. Riesmeier »

Have you disabled the DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS option in the CMake GUI?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest