DCMTK 字符集 Unicode 错误
DCMTK Character Set Unicode error
我正在使用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:DCMTKincludedcmtkoflogtracelog.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:DCMTKincludedcmtkoflogtracelog.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:DCMTKincludedcmtkoflogtracelog.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:DCMTKincludedcmtkoflogtracelog.h
Error 5 error C2665: 'dcmtk::log4cplus::Logger::getInstance' : none of the 2 overloads could convert all the argument types C:DCMTKincludedcmtkofloglogmacro.h
IntelliSense: no instance of overloaded function "dcmtk::log4cplus::Logger::getInstance" matches the argument list
argument types are: (const dcmtk::log4cplus::tchar *) c:DCMTKincludedcmtkofloglogmacro.h
IntelliSense: no operator "+" matches these operands
operand types are: const wchar_t [8] + dcmtk::log4cplus::tstring c:DCMTKincludedcmtkoflogtracelog.h
IntelliSense: no operator "+" matches these operands
operand types are: const wchar_t [8] + dcmtk::log4cplus::tstring c:DCMTKincludedcmtkoflogtracelog.h
IntelliSense: identifier "cerr" is undefined c:UsersKyleGoogle Drivecpp_codesdicomDicomTesttest1Source.cpp
IntelliSense: identifier "endl" is undefined c:UsersKyleGoogle Drivecpp_codesdicomDicomTesttest1Source.cpp
如果我设置Character Set: Use Multi-Byte Character Set
我可以解决
但是我需要在另一个项目中使用 DCMTK,其中字符集必须是 Unicode。查看错误,问题仅在某个关于日志记录的类中,可能我永远不会使用:所以我尝试注释出现错误的代码行,现在我可以使用 Unicode 进行编译。
这是解决问题的独特方法吗?评论该部分时我会遇到什么问题?
根据 DCMTK 的 INSTALL 文件:
"定义 UNICODE 或 _UNICODE 时,DCMTK 不会编译,因为 然后,VisualStudio编译器使用Unicode版本而不是ANSI 所有 Windows API 函数的版本(即键入 wchar_t 而不是字符 对于所有字符串参数和返回值)。
也许,您应该使用具有动态链接的 DCMTK(作为 DLL)。但是,这需要使用当前的开发快照,而不是最新版本(即 3.6.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:检测到"运行时库"不匹配:值"MTd_StaticDebug"与 DCMBase.obj 中的值"MDd_DynamicDebug"不匹配
没有标志,我能够毫无问题地使用编译的静态库。
希望这对某人有所帮助并保护很多时间。
问候
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- MinGW64 - Unicode 源文件错误?
- C++ wmain 函数错误时使用 Unicode
- 链接器错误:切换到unicode生成给出:未解析的外部符号WinMain
- 在将 unicode 替换为C++字符串中的空格时出现分段错误
- SQLGetPrivateProfileString 错误地读取 Unicode 字符
- 读取 CSV 文件(UNICODE 编码)C++时出现编码错误
- 为什么非unicode应用程序系统语言环境使Unicode字体具有错误显示的符号字符
- 使用 MinGW 输出日语文本的 Unicode 程序中C++错误
- DCMTK 字符集 Unicode 错误
- 如何解决此链接器错误(unicode、boost、TCHAR/tstring(visual studio 2008))
- 在MFC中序列化为Unicode文本文件-文件头错误
- 提振.program_options: implicit_value和Unicode会导致编译时错误
- XE5 Ansi/Unicode字符串链接器错误(未解决的外部)