4

I'm using the DCMTK library under Visual Studio 2013. In the properties of the Project if I set

Character Set: Use Unicode Character Set

When compiling I have the error

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)   C:\DCMTK\include\dcmtk\oflog\tracelog.h
Error   2   error C2664: 'void dcmtk::log4cplus::Logger::forcedLog(const dcmtk::log4cplus::spi::InternalLoggingEvent &) const' : cannot convert argument 3 from 'int' to 'const char *'   C:\DCMTK\include\dcmtk\oflog\tracelog.h 
Error   3   error C2678: binary '+' : no operator found which takes a left-hand operand of type 'const wchar_t [8]' (or there is no acceptable conversion)   C:\DCMTK\include\dcmtk\oflog\tracelog.h
Error   4   error C2664: 'void dcmtk::log4cplus::Logger::forcedLog(const dcmtk::log4cplus::spi::InternalLoggingEvent &) const' : cannot convert argument 3 from 'int' to 'const char *'   C:\DCMTK\include\dcmtk\oflog\tracelog.h
Error   5   error C2665: 'dcmtk::log4cplus::Logger::getInstance' : none of the 2 overloads could convert all the argument types   C:\DCMTK\include\dcmtk\oflog\logmacro.h
IntelliSense: no instance of overloaded function "dcmtk::log4cplus::Logger::getInstance" matches the argument list
            argument types are: (const dcmtk::log4cplus::tchar *)   c:\DCMTK\include\dcmtk\oflog\logmacro.h
IntelliSense: no operator "+" matches these operands
            operand types are: const wchar_t [8] + dcmtk::log4cplus::tstring   c:\DCMTK\include\dcmtk\oflog\tracelog.h
IntelliSense: no operator "+" matches these operands
            operand types are: const wchar_t [8] + dcmtk::log4cplus::tstring   c:\DCMTK\include\dcmtk\oflog\tracelog.h
IntelliSense: identifier "cerr" is undefined   c:\Users\Kyle\Google Drive\cpp_codes\dicom\DicomTest\test1\Source.cpp
IntelliSense: identifier "endl" is undefined   c:\Users\Kyle\Google Drive\cpp_codes\dicom\DicomTest\test1\Source.cpp

that I can solve if I set Character Set: Use Multi-Byte Character Set

But I need to use the DCMTK in another projet where the Character Set must be Unicode. Looking at the error the problem is only in some class about the Logging that probably I will never use: so I try to comment the line of code that get the error and now I can compile with Unicode.

This is the unique way to solve the problem? What problem I can have commenting that part?

GiordiX
  • 261
  • 5
  • 15
  • Technically speaking the "Character set" compiler option is a per-file option, so you could just change that. But then, maybe the rest of the project gets confused by the mixed declarations and explodes in other way... – rodrigo Jan 23 '15 at 10:40

2 Answers2

2

According to DCMTK's INSTALL file:

"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)."

Maybe, you should use DCMTK with dynamic linkage (as a DLL). However, this requires to use the current development snapshot and not the latest release (which is 3.6.0).

J. Riesmeier
  • 1,641
  • 10
  • 14
1

I run exactly into the same problem. This thread is some days old, but maybe someone can use this information. I found some threads with a similar problem, but without a satisfying solution.

We had the problem that we want to change the IDE from VS2008 to VS2015. All our (sub-)projects of our software solution were build with the UNICODE flag. And we had successfully integrated the DCMTK 3.6.1 within the UNICODE projects before.

I downloaded the latest DCMTK 3.6.1 build (3.6.1_20161102) and compiled it with VS2015. Then I tried to link and compile the static libraries to our software solution, but this failed (with same errors like described above).

After hours of unsuccessful tries with the static library, different CMake settings and the shared library suggestion (also with one complete shared DCMTK library), I tried another way. Because with the VS2008 IDE and UNICODE it was working already.

Finally I was successful, as I used an older DCMTK 3.6.1 build (3.6.1_20120222).

DCMTK 3.6.1 (20120222)

This build doesn't contain the following file:

dcmtk\oflog\tracelog.h

This file causes (in my case) the compiler and linker errors when the UNICODE flag was set for the target project.

Furthermore, when the flag DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS is activated, then I have received errors like below:

1>dcmnet.lib(assoc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in DCMBase.obj

Without the flag, I was able to use the compiled static libs without problems.

Hope this helps someone and safes a lot of hours.

Regards

gwythyr
  • 11
  • 3