D 语言 2.088.0 发布了,此版本共修复了 58 个 bug,并对编译器引入了 27
项主要更改。

gcc6.3编译c++11的程序链接opencv时字符型函数未定义,gcc6.3opencv

澳门新葡萄京官网注册,在Windows下编写图像处理程序,由于要使用regex,升级了mingw,编译c++11代码。之前代码中使用了opencv2.4.10,一直运行良好,升级编译器以后发现了错误:
undefined reference to
`cv::imread(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
int)’
原因:
If you get linker errors about undefined references to symbols that
involve types in the std::__cxx11 namespace or the tag [abi:cxx11]
then it probably indicates that you are trying to link together object
files that were compiled with different values for the
_GLIBCXX_USE_CXX11_ABI macro. This commonly happens when linking to
a third-party library that was compiled with an older version of GCC. If
the third-party library cannot be rebuilt with the new ABI then you will
need to recompile your code with the old ABI
Defining the following macro before including any standard library
headers should fix your problem:
#define _GLIBCXX_USE_CXX11_ABI 0

在Windows下编写图像处理程序,由于要使用regex,升级了mingw,编译c++11代码。之…

在Windows下编写图像处理程序,由于要使用regex,升级了mingw,编译c++11代码。之前代码中使用了opencv2.4.10,一直运行良好,升级编译器以后发现了错误:
undefined reference to
`cv::imread(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
int)’
原因:
If you get linker errors about undefined references to symbols that
involve types in the std::__cxx11 namespace or the tag [abi:cxx11]
then it probably indicates that you are trying to link together object
files that were compiled with different values for the
_GLIBCXX_USE_CXX11_ABI macro. This commonly happens when linking to
a third-party library that was compiled with an older version of GCC. If
the third-party library cannot be rebuilt with the new ABI then you will
need to recompile your code with the old ABI
Defining the following macro before including any standard library
headers should fix your problem:
#define _GLIBCXX_USE_CXX11_ABI 0

这是一个工作日版本,并没有什么更新亮点,大部分都是日常维护,不过其中 C++
互操作方面还是值得一说。

此版本分别在 DRuntime 模块 core.stdcpp.string 和 core.stdcpp.vector
中绑定了 std::string 和 std::vector,使得与 C++
的互操作性得到了很大的改进。其中存在一个兼容问题,需要注意。在 Linux
上编译时,当 D 使用 GCC 库和链接器,在使用符合 C++ 11 的现代版本的
std::string 时会出现兼容性问题。它包含一个内部指针,在 D
中既非法又与移动语义不兼容。解决方法是将 -D_GLIBCXX_USE_CXX11_ABI =
0 传递给 G++ 并使用 -version = _GLIBCXX_USE_CXX98_ABI 编译 D 应用。

详情查看更新说明:

https://dlang.org/blog/2019/09/06/dmd-2-088-0-released

(文/开源中国)