gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 11:30:21 25 4
gpt4 key购买 nike

我正在尝试使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com