在带有 mingw 编译器错误的 Windows 上进行 boost 测试:未声明 putenv [英] boost test on windows with mingw compiler error: putenv not declared

查看:65
本文介绍了在带有 mingw 编译器错误的 Windows 上进行 boost 测试:未声明 putenv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to compile a library on windows with mingw, that uses boost. I compiled boost with:

 bootstrap mingw
 b2 toolset=gcc 

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

After that I build the library with cmake and mingw. Building the dll itself works fine, but when I try to build the tests, I get:

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 标头,我不知道如何解决.

So the error comes from a boost header and I have no idea how to fix that.

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

The repo of what I'm trying to build: https://github.com/linges/daestruct

它使用 c99 和 c++11.

It uses c99 and c++11.

推荐答案

这似乎是 boost 中的一个错误.其他人也遇到过这种情况:

This seems to be a bug in boost. It has been happened to others, too:

https://github.com/BoostGSoC/boost.afio/commit/1b61a6e3e3e20a01a3c4461c6d2d54e16eb3c8e21/a>

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

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

The solution (or better: workaround) is to add the following lines before the inclusion of boost::test:

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

这篇关于在带有 mingw 编译器错误的 Windows 上进行 boost 测试:未声明 putenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆