Compiling the boost C++ library on AIX 7.1 using xlC 13.1.2 -
i trying compile regex part of boost c++ library on aix using xlc compiler , use 64-bit dynamic library, because need compare performance of several c++ regex libraries , built-in solutions, , boost seemed viable candidate.
here exact os , compiler versions:
$ uname -a aix host_name 1 7 00f9a2144c00 $ xlc -qversion ibm xl c/c++ aix, v13.1.2 (5725-c72, 5765-j07) version: 13.01.0002.0000
since not have root priviliges, cannot install boost library, trying compile regex part shared object file , obtain of needed headers test application. have tried compile latest available version (1.59.0), , version 1.55.0, because found ibm has released source code patch boost:
http://www-01.ibm.com/support/docview.wss?uid=swg27042921
i compile boost , copy headers , shared object file development folder using following commands:
bootstrap.sh --with-toolset=vacpp --prefix=/my/user/directory --exec-prefix=/my/user/directory ./b2 address-model=64 cxxflags=-q64 cflags=-q64 b2 tools/bcp ./dist/bin/bcp boost/regex.hpp /my/include/directory cp stage/lib/libboost_regex.so /my/library/directory
i know add --with-libraries=regex
flag compile regex part, irrelevant problems.
with both versions, or without patching boost source code, encounter same problems.
first: have libraries compiled, , linked simple test application, example pcre c++ regex library. when try link boost regex library, -lboost_regex
compile flag, following error:
ld: 0706-006 cannot find or open library file: -l boost_regex ld:open(): no such file or directory make: error code last command 255.
this resolved adding -brtl
compile flag, far know needed if try link static library, looks me if libboost_regex.so libboost_regex.a
second: when add line #include "boost/regex.hpp"
code, compilation error:
"/opt/ibm/xlc/13.1.2/include/xtr1common", line 217.19: 1540-0130 (s) "false_type" not declared. "/opt/ibm/xlc/13.1.2/include/xtr1common", line 223.19: 1540-0130 (s) "true_type" not declared. "/opt/ibm/xlc/13.1.2/include/xtr1common", line 229.19: 1540-0130 (s) "true_type" not declared. "/opt/ibm/xlc/13.1.2/include/xtr1common", line 235.19: 1540-0130 (s) "true_type" not declared. "/opt/ibm/xlc/13.1.2/include/xtr1common", line 244.11: 1540-0130 (s) "false_type" not declared. "/opt/ibm/xlc/13.1.2/include/xtr1common", line 250.11: 1540-0130 (s) "true_type" not declared. make: error code last command 1.
my test application simple. these contents of makefile:
all: /opt/ibm/xlc/13.1.2/bin/xlc -q64 -iinclude -llibs -lpcrecpp main.cpp -o regexp_test clean: rm regexp_test
here source code of basic test application:
#include <iostream> #include <string.h> #ifndef __ibmcpp_tr1__ #define __ibmcpp_tr1__ 1 #include <regex> #undef __ibmcpp_tr1__ #endif #define __ibmcpp_tr1__ 1 /* regular expression libraries included */ #include <sys/types.h> #include <regex.h> #include "pcrecpp.h" // #include "boost/regex.hpp" #include "deelx.h" int main(int argc, char **argv) { if(argc != 4){ std::cerr << "use: ./regexp_test <posix|tr1|pcre|deelx> value regexp" << std::endl; return 1; } int status; char buffer[256], regexp[256]; snprintf(buffer,sizeof(buffer),argv[2]); snprintf(regexp,sizeof(regexp),argv[3]); std::string buffer_string = buffer; bool match = false; if(strcmp(argv[1],"posix")==0){ regex_t comp; if (regcomp(&comp, regexp, reg_extended) != 0) { std::cerr << "the regular expression '" << regexp << "' not compiled!" << std::endl; return 1; } else { status = regexec(&comp, buffer, (size_t) 0, null, 0); regfree(&comp); if (status == 0) { match = true; } } } else if(strcmp(argv[1],"tr1")==0){ try { std::tr1::smatch matches; std::tr1::regex rgx(regexp); status = std::tr1::regex_search(buffer_string, matches, rgx); if(status){ match = true; } } catch(std::tr1::regex_error& re) { std::cerr << "tr1 exception caught!" << std::endl; } } else if(strcmp(argv[1],"pcre")==0){ pcrecpp::re re(regexp); if(re.partialmatch(buffer)){ match = true; } } else if(strcmp(argv[1],"deelx")==0){ static cregexpt <char> deelx_regexp(regexp, ignorecase | multiline); matchresult result = deelx_regexp.match(buffer); if(result.ismatched()){ match = true; } } else { std::cerr << "use: ./regexp_test <posix|tr1|pcre|deelx> value regexp" << std::endl; return 1; } if (!match) { std::cout << "the regular expression '" << regexp << "' not match value '" << buffer << "'." << std::endl; } else { std::cout << "the regular expression '" << regexp << "' matches value '" << buffer << "'." << std::endl; } return 0; }
how can these problems resolved? hints or advice appreciated.
i have found soltuion both of problems.
the problem linking:
i have found post: https://durgaprasad.wordpress.com/2006/09/28/problems-with-linking-of-shared-libraries-in-aix/
it details on aix, shared libraries can have both .so , .a suffix, , instruct compiler search .so files you'll need include -brtl
flag. instructs include -wl
flag, in order pass linkage flags directly linker (ld), have found version of xlc functionality deprecated.
the problem code:
the preprocessor instruction #define __ibmcpp_tr1__ 1
caused boost regex library fail compilation error. define needed built-in tr1 regular expressions of aix using, turns out required #include <regex>
part, can omit second define.
Comments
Post a Comment