PHP-CPP C++ Extension Can't Find Regex -



PHP-CPP C++ Extension Can't Find Regex -

this question has reply here:

is gcc 4.8 or before buggy regular expressions? 1 reply

i'm writing c++ extension php , i'm using regex in code. here snippet

#include <phpcpp.h> #include <regex> #include <iterator> #include <iostream> #include <sstream> #include <string> #include <fstream> #include <stdio.h> using namespace std; element* parse(std::sregex_iterator iterator, std::sregex_iterator iteratorend) { string segmentcontent = ""; // segment* segment = nullptr; while (iterator != iteratorend) { // segment = readsegment(iterator->str()); ++iterator; } homecoming nullptr; }; php::value parsefromfile(php::parameters &params) { string filepath = params[0]; ifstream file(filepath); if (!file.is_open()) { homecoming nullptr; } else { // read file buffer stringstream buffer; buffer << file.rdbuf(); // have buffer can close file file.close(); string regexpattern = string("some pattern here"); std::regex regexmatcher(regexpattern, regex_constants::icase); string filecontents = buffer.str(); std::sregex_iterator iterator(filecontents.begin(), filecontents.end(), regexmatcher); std::sregex_iterator iteratorend; root = parsexml(iterator, iteratorend); homecoming php::object("smartxmlparser\\xmlelement", root); } };

this won't compile haven't included parts of code (there lot.) compiles here without errors or warnings. when seek run test php file uses c++ code fails giving next error.

php warning: php startup: unable load dynamic library '/usr/lib/php5/20131226/myextension.so' - /usr/lib/php5/20131226/myextension.so: undefined symbol: _znst14regex_iteratorin9__gnu_cxx17__normal_iteratoripkcsseecst12regex_traitsiceec1ev in unknown on line 0 php fatal error: phone call undefined function parsexml() in /home/vagrant/laravel/extensions/myextension/test.php on line 5 php stack trace: php 1. {main}() /home/vagrant/laravel/extensions/myextension/test.php:0 fatal error: phone call undefined function parsexml() in /home/vagrant/laravel/extensions/myextension/test.php on line 5 phone call stack: 0.0023 220904 1. {main}() /home/vagrant/laravel/extensions/myextension/test.php:0

as remove methods , pieces of code reference regex classes runs fine (i can leave include , still work.)

i compile using these command lines:

g++ -wall -c -o2 -std=c++11 -fpic -o main.o main.cpp g++ -shared -o myextension.so main.o -lphpcpp cp -f myextension.so /usr/lib/php5/20131226 cp -f myextension.ini /etc/php5/cli/conf.d

since regex part of standard library in c++11 i'd imagine don't have link regex manually it's done automatically @ runtime right?

is there i'm missing create work php? i'm not exposing regex objects, they're means of achieving goal in c++ code.

regex available gcc version 4.9.0.

please update both gcc compiler , gcc runtime library version 4.9.0 or higher working.

note regex library gcc still not clean of bugs, , there a high-impact bug reported on stackoverflow.

c++ regex c++11 php-extension php-cpp

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -