Closed hchetia closed 3 years ago
Hi, this looks like it might be a compiler version issue. Can you post the output of g++ --version
?
Looks like maybe it's from gcc 4.8.2. I'm not sure if c++11 is supported in that version, which would cause the problem for regex
Hi The gcc version is 4.9.4.
Any chance you can directly show the output as requested above for g++? Also, there is 4.8.2 in the paths your compiler is trying to use to locate standard c++ headers (as shown in the error output). We use c++, not c, so if there is a discrepancy we need info on the g++ directly.
is this okay?
I am unsure why the compiler being used in 4.8.2!
Yes. Thanks. We will see if we can figure out why you got that problem.
Thanks andrew.
Hi I was wondering if you had an update on my issue. Thanks.
So from what I can see, the documentation says that c++11 is supported in g++ within most of GCC 4.8, which is seems you have. If you are working on a Mac, I know their c++ implementations have had bugs and lagged over the years, but mostly it's not a problem. So the issue seems to be with the regular expression <regex>
header. I'm pasting in some code you can use to test this. I want you to try and copy this code (which I copied from the Solarian Programmer's website) and see if it works: put it in a file named regex_test.cpp
and then run:
$ g++ -std=c++11 -o regex_test regex_test.cpp
The code itself is here:
// from the Solarian programmer
#include <iostream>
#include <regex>
#include <string>
using namespace std;
int main() {
string input;
regex integer("(\\+|-)?[[:digit:]]+");
//As long as the input is correct ask for another number
while(true) {
cout << "Give me an integer!" << endl;
cin >> input;
if (!cin) break;
// Exit when the user inputs q
if (input=="q")
break;
if (regex_match(input,integer))
cout << "integer" << endl;
else {
cout << "Invalid input" << endl;
}
}
}
If it compiles fine, you can test it like ./regex_test
and it will ask for some input, but we are mostly concerned with it compiling.
Hi I am using a Centos 6 system. g++ -std=c++11 -o regex_test regex_test.cpp command failed to run. Sharing the output with this comment.
Hi! Sorry for the late response - I'm not sure why the include headers and your compiler version are different, but I believe the issue ultimately boils down to your version of gcc not supporting the regex elements in our code. I am able to compile methpipe
with 5.1.1 but unable to when I switch to gcc 4.8.1. Could you try running make
on our code after switching to a newer version of gcc (maybe start with 5.x.x)?
I think the conclusion here is the compiler is just too old, it’s really too old to be supporting anymore anyway.
Hi, I noticed that this issue was closed. Just adding that I was able to build he program easily on my Mac OSX Catalina which uses gcc version 4.2.1. Yet building it on the Centos OS that uses 4.8.1 somehow failed.
Hi, I am trying to install methpipe in linux. I am successfully through the configure steps. At the make step, I get the following error-
make all-recursive make[1]: Entering directory
/rugpfs/fs0/hntz_lab/scratch/hchetia/softwares/methpipe-4.1.1/build' Making all in src/smithlab_cpp make[2]: Entering directory
/rugpfs/fs0/hntz_lab/scratch/hchetia/softwares/methpipe-4.1.1/build/src/smithlab_cpp' make all-am make[3]: Entering directory/rugpfs/fs0/hntz_lab/scratch/hchetia/softwares/methpipe-4.1.1/build/src/smithlab_cpp' CXX OptionParser.lo ../../../src/smithlab_cpp/OptionParser.cpp: In function ‘void read_config_file(const string&, std::vector<std::basic_string<char> >&)’: ../../../src/smithlab_cpp/OptionParser.cpp:371:54: error: no matching function for call to ‘regex_replace(std::string&, std::regex, const char [1])’ line = regex_replace(line, regex(outer_space), ""); ^ ../../../src/smithlab_cpp/OptionParser.cpp:371:54: note: candidates are: In file included from /usr/include/c++/4.8.2/regex:62:0, from ../../../src/smithlab_cpp/OptionParser.cpp:35: /usr/include/c++/4.8.2/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(const basic_string<_Ch_type>& __s, ^ /usr/include/c++/4.8.2/bits/regex.h:2182:5: note: template argument deduction/substitution failed: ../../../src/smithlab_cpp/OptionParser.cpp:371:54: note: mismatched types ‘const std::basic_string<_Ch_type>’ and ‘const char [1]’ line = regex_replace(line, regex(outer_space), ""); ^ In file included from /usr/include/c++/4.8.2/regex:62:0, from ../../../src/smithlab_cpp/OptionParser.cpp:35: /usr/include/c++/4.8.2/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, ^ /usr/include/c++/4.8.2/bits/regex.h:2162:5: note: template argument deduction/substitution failed: ../../../src/smithlab_cpp/OptionParser.cpp:371:54: note: deduced conflicting types for parameter ‘_Bi_iter’ (‘std::basic_regex<char>’ and ‘const char*’) line = regex_replace(line, regex(outer_space), ""); ^ ../../../src/smithlab_cpp/OptionParser.cpp:372:55: error: no matching function for call to ‘regex_replace(std::string&, std::regex, const char [2])’ line = regex_replace(line, regex(inner_space), " "); ^ ../../../src/smithlab_cpp/OptionParser.cpp:372:55: note: candidates are: In file included from /usr/include/c++/4.8.2/regex:62:0, from ../../../src/smithlab_cpp/OptionParser.cpp:35: /usr/include/c++/4.8.2/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(const basic_string<_Ch_type>& __s, ^ /usr/include/c++/4.8.2/bits/regex.h:2182:5: note: template argument deduction/substitution failed: ../../../src/smithlab_cpp/OptionParser.cpp:372:55: note: mismatched types ‘const std::basic_string<_Ch_type>’ and ‘const char [2]’ line = regex_replace(line, regex(inner_space), " "); ^ In file included from /usr/include/c++/4.8.2/regex:62:0, from ../../../src/smithlab_cpp/OptionParser.cpp:35: /usr/include/c++/4.8.2/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, ^ /usr/include/c++/4.8.2/bits/regex.h:2162:5: note: template argument deduction/substitution failed: ../../../src/smithlab_cpp/OptionParser.cpp:372:55: note: deduced conflicting types for parameter ‘_Bi_iter’ (‘std::basic_regex<char>’ and ‘const char*’) line = regex_replace(line, regex(inner_space), " "); ^ ../../../src/smithlab_cpp/OptionParser.cpp:389:64: error: no matching function for call to ‘regex_replace(std::string&, std::regex, const char [1])’ option_value = regex_replace(line, regex(outer_space), ""); ^ ../../../src/smithlab_cpp/OptionParser.cpp:389:64: note: candidates are: In file included from /usr/include/c++/4.8.2/regex:62:0, from ../../../src/smithlab_cpp/OptionParser.cpp:35: /usr/include/c++/4.8.2/bits/regex.h:2182:5: note: template<class _Rx_traits, class _Ch_type> std::basic_string<_Ch_type> std::regex_replace(const std::basic_string<_Ch_type>&, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(const basic_string<_Ch_type>& __s, ^ /usr/include/c++/4.8.2/bits/regex.h:2182:5: note: template argument deduction/substitution failed: ../../../src/smithlab_cpp/OptionParser.cpp:389:64: note: mismatched types ‘const std::basic_string<_Ch_type>’ and ‘const char [1]’ option_value = regex_replace(line, regex(outer_space), ""); ^ In file included from /usr/include/c++/4.8.2/regex:62:0, from ../../../src/smithlab_cpp/OptionParser.cpp:35: /usr/include/c++/4.8.2/bits/regex.h:2162:5: note: template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::basic_regex<_Ch_type, _Rx_traits>&, const std::basic_string<_Ch_type>&, std::regex_constants::match_flag_type) regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, ^ /usr/include/c++/4.8.2/bits/regex.h:2162:5: note: template argument deduction/substitution failed: ../../../src/smithlab_cpp/OptionParser.cpp:389:64: note: deduced conflicting types for parameter ‘_Bi_iter’ (‘std::basic_regex<char>’ and ‘const char*’) option_value = regex_replace(line, regex(outer_space), ""); ^ make[3]: *** [OptionParser.lo] Error 1 make[3]: Leaving directory
/rugpfs/fs0/hntz_lab/scratch/hchetia/softwares/methpipe-4.1.1/build/src/smithlab_cpp' make[2]: [all] Error 2 make[2]: Leaving directory `/rugpfs/fs0/hntz_lab/scratch/hchetia/softwares/methpipe-4.1.1/build/src/smithlab_cpp' make[1]: [all-recursive] Error 1 make[1]: Leaving directory `/rugpfs/fs0/hntz_lab/scratch/hchetia/softwares/methpipe-4.1.1/build' make: *** [all] Error 2