0

I'm trying to use odb for my first cpp project (based on progress database). I have installed everything i need and want to connect to my database. I wrote a simple instance for my database connection:

#include <odb/database.hxx>
#include <odb/pgsql/database.hxx>


int main(int argc, char *argv[]) {

std::unique_ptr<odb::database> db (
        new odb::pgsql::database (
                "postgres",     // database login name
                "postgres", // database password
                "test" // database name
        ));

and got this linking problem:

...: Undefined reference to `odb::pgsql::database::database(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, odb::details::transfer_ptr<odb::pgsql::connection_factory>)' collect2: error: ld returned 1 exit status

I think i need to extend my CMakeList.txt (still auto generated), but what i have to link ? ...

Brainfail
  • 196
  • 1
  • 2
  • 11
  • Make sure you compiled profile libraries for pgsql as described [here](https://www.codesynthesis.com/products/odb/doc/install-unix.xhtml). Then you need to link your application against both libodb-pgsql.so and libodb.so – mco Jan 04 '18 at 09:23
  • Thank you! I already solved my problem. I linked it totally wrong, it was my first time that i tried it manuel. – Brainfail Jan 05 '18 at 09:31
  • What did you do wrong and how did you solve it? I'm' having the same problem, but with SQLite and I'm clueless. – Piotr Masek Jun 21 '18 at 11:51

0 Answers0