我的mingw编译器:http: //sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.7.2/32-bit/threads-posix/sjlj/x32-4.7.2-release-posix-sjlj- rev6.7z
提升:http: //sourceforge.net/projects/boost/files/boost/1.52.0/boost_1_52_0.7z
(都在 D:驱动器上)
代码:
#include <boost\regex.hpp>
int main() {
boost::regex reg("[a-z]+");
}
命令行:
SET PATH=%PATH%;D:\mingw\bin;D:\mingw\include
g++ -I "d:\mingw\include" -I "d:\boost" -Os -s -o test.exe test.cpp -std=c++11 -static -L "D:\boost\stage\lib" -lboost_regex
目录中d:\boost\stage\lib
有libboost_regex-mgw47-mt-1_52.a
.
并且该过程返回:
d:/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lboost_regex
collect2.exe: error: ld returned 1 exit status
如果我输入 *.a 文件的确切名称,结果是cannot find -llibboost_regex-mgw47-mt-1_52.a
甚至整条路径-ld:\boost\stage\lib\libboost_regex-mgw47-mt-1_52.a
都行不通。无论我放在后面什么-l
都有相同的效果。