windows - 使用 mingw 编译器错误 : putenv not declared 在 Windows 上进行增强测试

标签 windows gcc c++11 mingw boost-test

我正在尝试使用 mingw 在 Windows 上编译一个使用 boost 的库。 我编译了 boost:

 bootstrap mingw
 b2 toolset=gcc 

之后,我使用 cmake 和 mingw 构建库。 构建 dll 本身工作正常,但是当我尝试构建测试时,我得到:

C:/boost/boost_1_55_0/boost/test/utils/runtime/config.hpp:95:51: error: 'putenv'
 was not declared in this scope
 putenv( const_cast<char*>( fs.str().c_str() ) );

所以错误来自 boost header ,我不知道如何解决。

我正在尝试构建的代码库:https://github.com/linges/daestruct

它使用 c99 和 c++11。

最佳答案

这似乎是 boost 中的一个错误。这也发生在其他人身上:

https://github.com/BoostGSoC/boost.afio/commit/1b06855b6e20a01a3c4461c6d2d54e16eb3c8e21

解决方案(或更好:解决方法)是在包含 boost::test 之前添加以下行:

#ifdef __MINGW32__
// Mingw doesn't define putenv() needed by Boost.Test
extern int putenv(char*);
#endif

关于windows - 使用 mingw 编译器错误 : putenv not declared 在 Windows 上进行增强测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21826649/

相关文章:

c++ - 删除绑定(bind)到成员函数的 vector<std::function<...>> 的任何元素

c - Windows 上的 libeio

windows - 在 C++ 中 Hook IDispatch v 表

c - 在 OS X 上使用 -m32 编译 union 的冗余大小

c - 如果启用优化器,GCC 浮点错误

c++ - 用于多个组件的索引技巧

c++ - 启用非模板成员函数,前提是它会进行类型检查

windows - 您可以通过 PKCS#11 向 Mozilla Firefox 公开 Windows 证书存储吗?

python - 如何在 Windows 中隐藏 Cygwin Python 控制台窗口?

c - 如何在CMake中添加.h/.o已编译的库