1
我想使用boost regex庫和創造了一個非常簡短的程序來測試我的makefile提升的makefile
#include <iostream>
#include <boost/regex.hpp>
using namespace std;
using namespace boost;
int main() {
regex exp("test");
cout << "Hello World" << endl;
}
這是我的makefile(我已經得到了提升,從這個線程包括Including boost libraries in make files)
EXEC = main
SOURCES = $(wildcard *.cpp)
HEADERS = $(wildcard *.h*)
OBJECTS = $(SOURCES:.cpp=.o)
all: $(EXEC)
main: $(OBJECTS)
g++ -L/usr/local/Cellar/boost/1.54.0/lib -lboost_filesystem-mt -lboost_thread-mt $(OBJECTS) -o $(EXEC)
%.o: %.cpp $(HEADERS)
g++ -I/usr/local/Cellar/boost/1.54.0/include -c $< -o [email protected]
clean:
rm -f $(EXEC) $(OBJECTS)
當我編譯我的程序收到以下錯誤信息:
g++ -I/usr/local/Cellar/boost/1.54.0/include -c main.cpp -o main.o
g++ -L/usr/local/Cellar/boost/1.54.0/lib -lboost_filesystem-mt -lboost_thread-mt main.o -o main
Undefined symbols for architecture x86_64:
"boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)", referenced from:
boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int)in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [main] Error 1
缺少什麼? 我已經在Mac OS X 10.8下安裝了自制軟件。
這可能是值得指出的是,蘋果公司的執行STL包含C++ 11 [STL正則表達式](http://www.cplusplus.com/reference/regex/)。 – zneak