windows上带mingw编译器的boost测试错误:未声明putenv

windows上带mingw编译器的boost测试错误:未声明putenv,windows,gcc,c++11,mingw,boost-test,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

我正试图用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() ) );
C:/boost/boost\u 1\u 55\u 0/boost/test/utils/runtime/config.hpp:95:51:错误:“putenv”
未在此范围中声明
putenv(const_cast(fs.str().c_str());
所以这个错误来自一个boost头,我不知道如何修复它

我试图建立的回购协议:


它使用c99和c++11。这似乎是boost中的一个bug。这也发生在其他人身上:

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

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

用C++代码编写一个C++库集合,STD < /COD>标志当然是误导的…好点!那是试图建立图书馆的产物。我把它拿走了。