Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8227341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:05:55+00:00 2026-06-07T16:05:55+00:00

I want to finally get to know how to write an application which uses

  • 0

I want to finally get to know how to write an application which uses database. I chose C++, PostgreSQL and SOCI (SQL wrapper to C++). I use Xubuntu 11.4 and installed everyting which was necessary to run a simple program.

To use SOCI I installed:

1) libboost-dev
2) libpq-dev
3) libtool
4) SOCI, using this: http://soci.sourceforge.net/doc/backends/postgresql.html#required and I compiled SOCI with this command: cmake cmake -G “Unix Makefiles” -DWITH_BOOST=ON -DWITH_POSTGRESQL=ON ../

My simple program is veeery simple:

#include "soci-postgresql.h"

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

  soci::session sql(postgresql, "testDB");
  return 0;
}

I compile it like this:

g++ test.cpp -lsoci_core -lsoci_postgresql -ldl -lpq

but it gives me error:

test.cpp:1:29: fatal error: soci-postgresql.h: No such file or
directory compilation terminated.

How to fix this, whats wrong? Did I miss to install something?

Some more infos:

/usr/local/include/soci$ ls

backend-loader.h        postgresql                  soci-platform.h
blob-exchange.h         prepare-temp-type.h         soci-simple.h
blob.h                  procedure.h                 statement.h
boost-fusion.h          ref-counted-prepare-info.h  transaction.h
boost-gregorian-date.h  ref-counted-statement.h     type-conversion.h
boost-optional.h        row-exchange.h              type-conversion-traits.h
boost-tuple.h           row.h                       type-holder.h
connection-pool.h       rowid-exchange.h            type-ptr.h
empty                   rowid.h                     unsigned-types.h
error.h                 rowset.h                    use.h
exchange-traits.h       session.h                   use-type.h
into.h                  soci-backend.h              values-exchange.h
into-type.h             soci-config.h               values.h
once-temp-type.h        soci.h                      version.h

/usr/local/include/soci/postgresql$ ls
common.h  soci-postgresql.h

/usr/local/lib$ ls
libCOS4.a                      libomniORB4.so.1
libCOS4.so                     libomniORB4.so.1.6
libCOS4.so.1                   libomnithread.a
libCOS4.so.1.6                 libomnithread.so
libCOSDynamic4.a               libomnithread.so.3
libCOSDynamic4.so              libomnithread.so.3.4
libCOSDynamic4.so.1            libsoci_core.a
libCOSDynamic4.so.1.6          libsoci_core.so
libomniCodeSets4.a             libsoci_core.so.3.1
libomniCodeSets4.so            libsoci_core.so.3.1.0
libomniCodeSets4.so.1          libsoci_empty.a
libomniCodeSets4.so.1.6        libsoci_empty.so
libomniConnectionMgmt4.a       libsoci_empty.so.3.1
libomniConnectionMgmt4.so      libsoci_empty.so.3.1.0
libomniConnectionMgmt4.so.1    libsoci_postgresql.a
libomniConnectionMgmt4.so.1.6  libsoci_postgresql.so
libomniDynamic4.a              libsoci_postgresql.so.3.1
libomniDynamic4.so             libsoci_postgresql.so.3.1.0
libomniDynamic4.so.1           pkgconfig
libomniDynamic4.so.1.6         python2.7
libomniORB4.a                  python3.2
libomniORB4.so

I also tried this one: g++ test.cpp -lsoci_core -lsoci_postgresql -ldl -lpq -I /usr/local/include/soci/postgresql and got the error:

g++ test.cpp -lsoci_core -lsoci_postgresql -ldl -lpq -I
/usr/local/include/soci/postgresql In file included from test.cpp:1:0:
/usr/local/include/soci/postgresql/soci-postgresql.h:27:26: fatal
error: soci-backend.h: No such file or directory compilation
terminated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:05:56+00:00Added an answer on June 7, 2026 at 4:05 pm

    Ok guys, I found a solution on a polish programming website.

    My new code (socitest.cpp):

    #include <iostream>
    #include <soci.h>
    #include <postgresql/soci-postgresql.h>
    
    int main(int argc, char **argv)
    {
       try
       { 
          soci::session sql(soci::postgresql, "dbname=testDB");
       }
       catch (soci::postgresql_soci_error const & e)
       {
          std::cerr << "PostgreSQL error: " << e.sqlstate() << " " << e.what() << std::endl;
       }
       catch (std::exception const & e)
       {
          std::cerr << "Some other error: " << e.what() << std::endl;
       }
       return 0;
    
    }
    

    And I have to compile it :

    g++ socitest.cpp -lsoci_core -lsoci_postgresql -ldl -lpq -I
    /usr/local/include/soci -I /usr/include/postgresql -o socitest

    It should compile but it might not run. If it’s not running, I have to do sth more:

    1) create soci.conf file:

    touch /etc/ld.so.conf.d/soci.conf

    2) edit my soci.conf with gedit:

    gedit /etc/ld.so.conf.d/soci.conf

    3) paste in soci.conf:

    /usr/local/lib64

    (for Xubuntu x64) or

    /usr/local/lib

    (for Xubuntu x32) and save file

    4) run command:

    ldconfig

    5) run my compiled socitest like this: ./socitest and it’s wooooorking !!! 😀

    Thanks all of you for helping me:)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm finally starting to use rest in rails. I want to have a
I want to write script in SQL that will copy these 2 tables(A,B) to
So I have access to a dedicated server and want to finally create my
This is a question I have frequently, and finally want to hear people's opinions
I finally have my C++ Builder 2010 installation the way I want it, with
want to know why String behaves like value type while using ==. String s1
want to have a Hyperlink-Button in a gridView in which I can display a
I want to make one SqlBulkCopy method that I can use for all my
I think I finally get the point of constraints, but still a bit confused.
I have 5 processes p1,p2,...,p5 where I want to write some data to stdin

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.