1

I'm trying to test a connection to my postgreSQL database. I've installed libpqxx from here The official C++ client API for PostgreSQL.

I'm using the latest version of CLion for my project, GCC 8.1 on Fedora 28 OS. and I'm going to use the C++11 standard. When I try to compile my code I get:

/usr/local/include/pqxx/internal/statement_parameters.hxx:213:13: error: ‘experimental’ in namespace ‘std’ does not name a type
      const std::experimental::optional<Arg> &arg)
             ^~~~~~~~~~~~
/usr/local/include/pqxx/internal/statement_parameters.hxx:213:35: error: expected unqualified-id before ‘<’ token
      const std::experimental::optional<Arg> &arg)
                                   ^
/usr/local/include/pqxx/internal/statement_parameters.hxx:213:35: error: expected ‘)’ before ‘<’ token
  const std::experimental::optional<Arg> &arg)
                                   ^
                                   )
/usr/local/include/pqxx/internal/statement_parameters.hxx:212:40: note: to match this ‘(’
   template<typename Arg> void add_field(
                                        ^
/usr/local/include/pqxx/internal/statement_parameters.hxx:213:35: error: expected initializer before ‘<’ token
  const std::experimental::optional<Arg> &arg)

So I think there is something wrong with my libpqxx configuration or my usage of it.

  1. Do I have to include some Information on pqxx in the CMakeLists.txt or does the usage of #include <pqxx/pqxx> is enough? Using the #include <pqxx/pqxx> doesn't output any unrecognized errors.
  2. Do I have to configure the libpqxx to use C++11 and reinstall it. If yes, what is the right flag to use for setting a specific C++ standard when executing ./configure? I didn't find any information on that in the official Site and on the internet.
  3. Do I have to add some setting in CLion to build my project with C++11?
TalG
  • 677
  • 1
  • 9
  • 26
  • 2
    The errors are complaining about `experimental::optional` rather than libpqxx, and I think that was part of C++11. Therefore this might help [How to enable C++11 in CLion?](https://stackoverflow.com/questions/26317981/how-to-enable-c11-in-clion) – acraig5075 Jun 11 '18 at 14:41
  • @acraig5075 I already use the `set(CXX_STANDARD 11)` option in my **CMakeFile** – TalG Jun 11 '18 at 14:49
  • @acraig5075 In the end it was the solution I've been searching for. – TalG Jun 11 '18 at 20:04
  • I had to use also the instructions here [Allow build to hide std::experimental::optional](https://github.com/jtv/libpqxx/commit/291db1079f98396b2de4ff9f9adec0044666a905) – TalG Jun 11 '18 at 20:41

0 Answers0