为了在我的 MacOS X 环境中安装 Virtuoso,我使用了 brew 端口,即:
brew install virtuoso
通过这样做,它自动安装了一些 ODBC/iODBC 驱动程序,这些驱动程序不能被任何其他 unixodbc 设置覆盖。特别是如果我尝试链接这样的库:
$ brew link unixodbc
Linking /usr/local/Cellar/unixodbc/2.3.4...
Error: Could not symlink bin/isql
Target /usr/local/bin/isql
is a symlink belonging to virtuoso. You can unlink it:
brew unlink virtuoso
To force the link and overwrite all conflicting files:
brew link --overwrite unixodbc
To list all files that would be deleted:
brew link --overwrite --dry-run unixodbc
顺便说一句,我不想取消链接这个版本。所以我尝试从头开始编译 Redland 并从 GitHub 下载。特别是,我使用了两种可能的配置:
env PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure --with-virtuoso --with-odbc=/usr/local/Cellar/virtuoso/7.2.4.2
env PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure --with-virtuoso --with-iodbc=/usr/local/Cellar/virtuoso/7.2.4.2
手动添加rdf_hash_internal.h
并rdf_heuristics.h
在我的项目中后,一切顺利,一切都得到编译和链接。在我的 C++ 应用程序中,我尝试使用以下代码访问数据库:
world = librdf_new_world();
librdf_world_open(world);
storage = librdf_new_storage(world,"virtuoso",graphName.c_str(),"dsn='Local Virtuoso',user='dba',password='dba'");
model = librdf_new_model(world,storage,NULL);
context_node = librdf_new_node_from_uri_string(world,(const unsigned char*)defaultContext.c_str());
/* librdf_model_transaction_commit(this->super->model) */
librdf_model_size(super->model)
如果我禁用事务,无论如何我在“rdf_storage_virtuoso.c”的第 941 行收到以下错误:
rc = SQLDriverConnect(connection->hdbc, 0,(UCHAR *) context->conn_str,
SQL_NTS, context->outdsn,
LIBRDF_VIRTUOSO_CONTEXT_DSN_SIZE,
&buflen, SQL_DRIVER_COMPLETE);
因此,我认为 ODBC/iODBC 级别存在连接错误。顺便说一句,我可以使用以下命令连接到 virtuoso:
$ isql localhost:1111 dba dba
Connected to OpenLink Virtuoso
Driver: 07.20.3217 OpenLink Virtuoso ODBC Driver
OpenLink Interactive SQL (Virtuoso), version 0.9849b.
Type HELP; for help and EXIT; to exit.
SQL>
有没有办法将 Redland 库与 Virtuoso 的 ODBC 库连接起来?提前致谢。