2013-01-05 39 views
0

此代碼編譯正常:如何正確鏈接boost正則表達式?

#include <boost\regex.hpp> 
int main() { 
    boost::regex reg("[a-z]+"); 
} 

但是,在涉及到連接有錯誤消息:

d:/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: final link failed: Invalid operation 
collect2.exe: error: ld returned 1 exit status 

必須我把命令行選項是什麼? 我目前的開關是:

-I "d:\mingw\include" -I "d:\boost" -Os -s -o "test.exe" "test.cpp" -std=c++11 -ftree-vectorize -static 

回答

2

嘗試增加-lboost_regex-lboost_regex-mt

+0

沒有這些工作,我:'d:/ MinGW的/ bin中/../ lib中/ GCC/i686的-W64-mingw32的/ 4.7.2 /../../../../ i686-w64-mingw32/bin/ld.exe:找不到-lboost_regex或ld.exe:找不到-lboost_regex-mt – rsk82

+0

有沒有D:\ boost下的某個庫? (* .a或* .dll)您可能需要在-l之前添加-L path-to-libraries-directory。 –

+0

嗯,沒有...我從這裏得到了提升:'http:// sourceforge.net/projects/boost/files/boost/1.52.0/boost_1_52_0.7z'並且沒有這樣的文件。如何獲得他們? – rsk82