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.
I believe I have found the issue. Doing a:
Outputs the following:
By looking at it you can clearly see that it searches
/usr/local/lib/only forsoci_corewhereas normally it should search forsoci_sqlite3as well. A quick and dirty hack that fixes the problem is to create a smylink tolibsoci_sqlite3.so.3.1in any of the other folders listed there but I’m quite sure that there is a better way of fixing it.