mingw的编译发行版常见的有两个: MinGW Distro 和 TDM-GCC. MinGW Distro中更是包含了boost库,不用我们再编译,而且都是最新的库,非常方便。可以去这里下载点击打开链接,
下载最新版 mingw-13.0.exe,将Code Blocks 的安装目录下的MinGW下的文件全部删除,之后将下载的文件双击, 提取到MinGW文件夹下。
之后启动Code Blocks,会提示检测不到编译器。
将编译器所在的目录收到改为新的MinGW \ bin 下,另外将当前的对应工具从mingw32版本改为目录下对应的版本。
boost库大部分直接包含头文件.hpp文件即可以使用,少部分需要编译,比如正则表达式:
Code Blocks库下的boost的正则表达式的使用方法如下:
1、在设置--编译器设置里,添加boost库的所有头文件到搜索路径:
2、在连接器中,添加正则表达式对应的链接库文件:
添加测试代码:
#include <stdio.h>
#include <string>
#include <iterator>
#include <boost/regex.hpp>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
std::string str("infoasdf123unil98oasdfa686^&*(432");
boost::regex e1("[0-9]+");
std::string::const_iterator start, end;
start = str.begin();
end = str.end();
boost::match_results<std::string::const_iterator> what;
boost::match_flag_type flags = boost::match_default;
while (regex_search(start, end, what, e1, flags))
{
cout << "finded number: " << string(what[0].first, what[0].second) << endl;
start = what[0].second;
}
return 0;
}
正常运行,得到结果:
nuwen.net 是微软员工个人编译的Mingw 版本,使用的线程模型是win32 (gcc -v可查看),所以有些C++11的特性无法使用。
以下部分摘自:点击打开链接
GCC Threading model (posix vs win32)
Mingw-Builds (and the experimental rubenvb packages) also let you choose between the threading model internally used by (lib)gcc:
- posix (built upon MinGW-w64's winpthreads)
- "an implementation of POSIX threads for win32 is also available under the experimental directory. Its main goal is to support C+11 standard threading, which supports only using POSIX threads at the moment."http://mingw-w64.sourceforge.net/
- enables C11 library features contained in the headers <thread>, <mutex>, and <future>.
- Performance degradation in specific scenarios. C11 functionality is significantly slower than native Win32 implementation or even MSVS2012's implementation.
- win32
- uses native Win32 threading functions.
- no C11 <thread>, <mutex>, or <future>
- best performance
More reading: http://sourceforge.net/mailarchive/message.php?msg_id=28014658