I have these packages installed on my OpenSUSE 11.3:
i | libstdc++45 | Standard shared library for C++ | package
i | libstdc++45-devel | Contains files and libraries for development | package
But when i'm trying to compile this C++ code:
#include <stdio.h>
#include <tr1/regex>
using namespace std;
int main() {
int test[2];
const tr1::regex pattern(".*");
test[0] = 1;
if (tr1::regex_match("anything", pattern) == false) {
printf("Pattern does not match.\n");
}
return 0;
}
using
g++ -pedantic -g -O1 -o ./main.o ./main.cpp
It outputs this errors:
./main.cpp: In function ‘int main()’:
./main.cpp:13:43: error: ‘printf’ was not declared in this scope
radek@mypc:~> nano main.cpp
radek@mypc:~> g++ -pedantic -g -O1 -o ./main.o ./main.cpp
/tmp/cc0g3GUE.o: In function `basic_regex':
/usr/include/c++/4.5/tr1_impl/regex:771: undefined reference to `std::tr1::basic_regex<char, std::tr1::regex_traits<char> >::_M_compile()'
/tmp/cc0g3GUE.o: In function `bool std::tr1::regex_match<char const*, char, std::tr1::regex_traits<char> >(char const*, char const*, std::tr1::basic_regex<char, std::tr1::regex_traits<char> > const&, std::bitset<11u>)':
/usr/include/c++/4.5/tr1_impl/regex:2144: undefined reference to `bool std::tr1::regex_match<char const*, std::allocator<std::tr1::sub_match<char const*> >, char, std::tr1::regex_traits<char> >(char const*, char const*, std::tr1::match_results<char const*, std::allocator<std::tr1::sub_match<char const*> > >&, std::tr1::basic_regex<char, std::tr1::regex_traits<char> > const&, std::bitset<11u>)'
collect2: ld returned 1 exit status
What packages should i (un)install to make the code work on my PC?