我正面临一个恼人的问题,一直困扰我从编程中恢复过来。 我打算开始一个个人项目,我需要使用数据库来存储某些信息,然后我决定使用SQLite,但我不喜欢C-ish API,所以我在SQLite wiki中遇到了SOCI包装器。

我去了官方的SOCI网站,阅读文档并决定试一试。 我按照文档“安装”一章中的说明进行操作,在安装完所有要求后,我编译并安装它:

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

所有测试都成功完成但是在尝试运行时(在使用g++ test.cpp -o1 -lsoci_core -lsoci_sqlite3编译之后)这样的程序如下:

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;    
}

我收到一条错误消息:“加载共享库时出错:libsoci_sqlite3.so.3.1:无法打开共享对象文件:没有这样的文件或目录。” 但是看一下安装日志,我可以清楚地看到已经安装了共享库。

===============>>#1 票数:3 已采纳

我相信我找到了这个问题。 做一个:

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

输出以下内容:

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

通过查看它,您可以清楚地看到它在/usr/local/lib/搜索soci_core而通常它也应该搜索soci_sqlite3 修复问题的快速而肮脏的黑客是在libsoci_sqlite3.so.3.1中创建了一个smylink到其中libsoci_sqlite3.so.3.1的任何其他文件夹,但我很确定有更好的方法来修复它。

===============>>#2 票数:0

在您的SOCI安装库中,库位于/ usr / local / lib64 /

以下声明应该有效:

g ++ test.cpp -o test -I / usr / local / include / soci -L / usr / local / lib64 / -lsoci_core -lsoci_sqlite3 \\
-Wl,-rpath =的/ usr /本地/ lib64下/

  ask by Mihai Bişog translate from so

未解决问题?本站智能推荐: