Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you properly install SOCI?

I'm facing an annoying problem that has been holding me back from programming for some time. I intend to start a personal project in which I need to use a database to store certain information and I decided to use SQLite however I did not like the C-ish API so I came across SOCI wrapper in the SQLite wiki.

I went to the official SOCI website, read the documentation and decided to give it a go. I followed the instructions in the 'Installation' chapter of the documentation and after installing all requirements I compiled it and installed it with:

cmake -DWITH_BOOST=ON -DSOCI_TESTS=ON -DWITH_SQLITE3=ON
make
make test
sudo make install

All tests completed successfully however when trying to run (after compiling with g++ test.cpp -o1 -lsoci_core -lsoci_sqlite3) a program such as this one:

test.cpp:

#include "soci/soci.h"
#include "soci/sqlite3/soci-sqlite3.h"
#include <iostream>

int main()
{
    soci::session sql(soci::sqlite3, "testdb.db");

    return 0;    
}

I get an error saying: "Error while loading shared libraries: libsoci_sqlite3.so.3.1: cannot open shared object file: No such file or directory." but looking at the install log I can clearly see that the shared library is installed.

like image 913
Mihai Bişog Avatar asked Dec 11 '11 20:12

Mihai Bişog


1 Answers

I believe I have found the issue. Doing a:

strace -e open ./1 2>&1 | grep soci

Outputs the following:

open("/usr/local/lib/libsoci_core.so.3.1", O_RDONLY) = 3
open("/lib/x86_64-linux-gnu/tls/x86_64/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/tls/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/x86_64/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/tls/x86_64/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/tls/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/x86_64/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/tls/x86_64/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/tls/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/x86_64/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/x86_64/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/libsoci_sqlite3.so.3.1", O_RDONLY) = -1 ENOENT (No such file or directory)
./1: error while loading shared libraries: libsoci_sqlite3.so.3.1: cannot open shared object file: No such file or directory

By looking at it you can clearly see that it searches /usr/local/lib/ only for soci_core whereas normally it should search for soci_sqlite3 as well. A quick and dirty hack that fixes the problem is to create a smylink to libsoci_sqlite3.so.3.1 in any of the other folders listed there but I'm quite sure that there is a better way of fixing it.

like image 56
Mihai Bişog Avatar answered Nov 11 '22 04:11

Mihai Bişog