[英]boost makefile on Mac OS X
我想使用boost regex庫並創建一個非常短的程序來測試我的makefile
#include <iostream>
#include <boost/regex.hpp>
using namespace std;
using namespace boost;
int main() {
regex exp("test");
cout << "Hello World" << endl;
}
這是我的makefile(我從這個線程中獲得了包括make文件中的boost庫 )
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 $@
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下用自制軟件安裝了boost。
您缺少指向boost_regex_mt庫的鏈接
-lboost_filesystem-mt -lboost_thread-mt
在你的makefile中......
main: $(OBJECTS)
g++ -L/usr/local/Cellar/boost/1.54.0/lib -lboost_regex-mt -lboost_filesystem-mt -lboost_thread-mt $(OBJECTS) -o $(EXEC)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.