我正在使用Visual Studio 2013下的DCMTK库。
在项目的属性中,如果我设置

Character Set: Use 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)   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

如果设置Character Set: Use Multi-Byte Character Set我可以解决

但是我需要在另一个字符集必须为Unicode的项目中使用DCMTK。在查看错误时,问题仅存在于可能永远不会使用的有关Logging的某个类中:因此,我尝试注释出现错误的代码行,现在可以使用Unicode进行编译了。

这是解决问题的独特方法吗?我可以在那部分评论什么问题?

最佳答案

根据DCMTK的INSTALL文件:

“定义UNICODE或_UNICODE时,DCMTK无法编译,因为
然后,VisualStudio编译器使用Unicode版本而不是ANSI版本
所有Windows API函数的版本(即,键入wchar_t而不是char
所有字符串参数和返回值)。”

也许,您应该将DCMTK与动态链接一起使用(作为DLL)。但是,这需要使用当前的开发快照而不是最新版本(3.6.0)。

10-04 13:51