Boost regex library problem on Mac
Greetings I am using some simple boost regex code: const boost::regex eparse("^([[:digit:]]+).*"); (in a header file) boost::cmatch matches; (in a cpp file) from the subroutine if (boost::regex_match(edit.c_str(), matches, eparse)) { // matches[0] contains the original string. matches[n] // contains a sub_match object for each matching // subexpression for (int i = 1; i < matches.size(); i++) { // sub_match::first and sub_match::second are iterators that // refer to the first and one past the last chars of the // matching subexpression std::string match(matches[i].first, matches[i].second); std::cout << "\tmatches[" << i << "] = " << match << std::endl; } } with a makefile: CXXFLAGS = -O2 -g -Wall -fmessage-length=0 -I/usr/local/boost_1_39_0 OBJS = CrossMapper.o CrossMap.o Read.o Target.o LIBS = -L/lib -lboost_regex-xgcc40-mt-1_39 INCLUDE= /usr/local/boost_1_39_0 TARGET = CrossMapper $(TARGET): $(OBJS) $(CXX) -o $(TARGET) $(OBJS) $(LIBS) all: $(TARGET) clean: rm -f $(OBJS) $(TARGET) It links but will not load: Macintosh-8:~/Documents/workspace/CrossMapper mmuratet$ ./CrossMapper dyld: Library not loaded: libboost_regex-xgcc40-mt-1_39.dylib Referenced from: /Users/mmuratet/Documents/workspace/CrossMapper/./ CrossMapper Reason: image not found Trace/BPT trap Macintosh-8:~/Documents/workspace/CrossMapper mmuratet$ I've been chasing this for several hours and can't get anywhere. Can anyone offer any suggestions? Thanks Mike
Mike, greetings --
Michael Muratet
if (boost::regex_match(edit.c_str(), matches, eparse)) {
As an aside, is 'edit' a std::string? regex_match should be able to deal with that directly, no need for c_str().
It links but will not load:
Macintosh-8:~/Documents/workspace/CrossMapper mmuratet$ ./CrossMapper dyld: Library not loaded: libboost_regex-xgcc40-mt-1_39.dylib Referenced from: /Users/mmuratet/Documents/workspace/CrossMapper/./ CrossMapper Reason: image not found Trace/BPT trap Macintosh-8:~/Documents/workspace/CrossMapper mmuratet$
I've been chasing this for several hours and can't get anywhere. Can anyone offer any suggestions?
Is /lib in your runtime library search path? On linux, that's LD_LIBRARY_PATH. Looks like it's DYLD_LIBRARY_PATH on OSX. You might also be able to use rpath in the link step, where the link stores the path to the library as found at link time, instead of having dyld search for it at runtime. I think you want: -Wl,-rpath On the g++ command line. Good luck! Tony
participants (2)
-
Anthony Foiani
-
Michael Muratet