[英]boost makefile on Mac OS X
I'd like to use boost regex library and created a very short program to test my makefile 我想使用boost regex库并创建一个非常短的程序来测试我的makefile
#include <iostream>
#include <boost/regex.hpp>
using namespace std;
using namespace boost;
int main() {
regex exp("test");
cout << "Hello World" << endl;
}
Here is my makefile (I've got the boost includes from this thread Including boost libraries in make files ) 这是我的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)
When I compile my program a get the following error message: 当我编译我的程序时,获取以下错误消息:
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
What is missing? 什么东西少了? I've installed boost with homebrew under Mac OS X 10.8.
我在Mac OS X 10.8下用自制软件安装了boost。
You are missing a link to the boost_regex_mt library 您缺少指向boost_regex_mt库的链接
-lboost_filesystem-mt -lboost_thread-mt -lboost_filesystem-mt -lboost_thread-mt
In your makefile... 在你的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.