DCMTK字符集Unicode错误

时间:2015-01-23 09:25:34

标签: c++ unicode visual-studio-2013 dicom dcmtk

我在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编译。

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

2 个答案:

答案 0 :(得分:2)

根据DCMTK的INSTALL文件:

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

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

答案 1 :(得分:0)

我遇到了同样的问题。这个帖子有些日子了,但也许有人可以使用这些信息。我找到了一些类似问题的线程,但没有令人满意的解决方案。

我们遇到的问题是我们要将IDE从VS2008更改为VS2015。我们软件解决方案的所有(子)项目都使用UNICODE标志构建。我们之前已成功将DCMTK 3.6.1集成到UNICODE项目中。

我下载了最新的 DCMTK 3.6.1 版本( 3.6.1_20161102 )并使用VS2015进行了编译。然后我尝试将静态库链接并编译到我们的软件解决方案中,但这失败了(具有如上所述的相同错误)。

使用静态库,不同的CMake设置和共享库建议(还有一个完整的共享DCMTK库)尝试不成功数小时后,我尝试了另一种方法。因为VS2008 IDE和UNICODE已经可以使用了。

最后我成功了,因为我使用的是较旧的 DCMTK 3.6.1 版本( 3.6.1_20120222 )。

DCMTK 3.6.1 (20120222)

此版本不包含以下文件:

  

DCMTK \ oflog \ tracelog.h

当为目标项目设置UNICODE标志时,此文件会导致(在我的情况下)编译器和链接器错误。

此外,当激活标志 DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS 时,我收到如下错误:

  

1> dcmnet.lib(assoc.obj):错误LNK2038:检测到' RuntimeLibrary':值' MTd_StaticDebug'没有匹配的价值' MDd_DynamicDebug'在DCMBase.obj

没有标志,我就可以毫无问题地使用已编译的静态库。

希望这可以帮助某人和保险箱很长时间。

此致

相关问题