0

In order to install Virtuoso on my MacOS X environment, i used the brew port, that is:

brew install virtuoso

By doing so, it automatically installed some ODBC/iODBC drivers, that could not be overwritte by any other unixodbc setup. In particular if I try to link such library:

$ 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

By the way, I do not want to unlink this version. So I tried to compile Redland from scratch and download it from GitHub. In particular, I used two possible configurations:

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

After adding rdf_hash_internal.h and rdf_heuristics.h in my project manually, everything just goes smoothly and everything gets both compiled and linked. In my C++ app, I'm trying to access the database with the following code:

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)

If either I disable the transaction or not, anyway I got the following error at line 941 of "rdf_storage_virtuoso.c":

rc = SQLDriverConnect(connection->hdbc, 0,(UCHAR *) context->conn_str,
                      SQL_NTS, context->outdsn,
                      LIBRDF_VIRTUOSO_CONTEXT_DSN_SIZE,
                      &buflen, SQL_DRIVER_COMPLETE);

Hence, I suppose there is a connection error at the ODBC/iODBC level. By the way, I could connect to virtuoso with the following command:

$ 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>

Is there any way to connect the Redland library with ODBC library by Virtuoso? Thanks in advance.

jackb
  • 695
  • 8
  • 26

3 Answers3

2

All those troubles were due to a configuration issue that AFIK was described in no guide (Correct me if I'm wrong, I'd like to find more details on both Virtuoso and Redland/librdf). Hereby, as I told in the comments, the problem was in ODBC, but the reason was that there is no mention in no Virtuoso guide how to configure their driver. This is the way to go:

/Library/ODBC/odbc.ini

[ODBC Data Sources]
VOS = virtuoso-odbc

[VOS]
Driver = /usr/local/Cellar/virtuoso/7.2.4.2/lib/virtodbc.so
Description = Virtuoso Open-Source Edition
Address = localhost:1111
UserName    = dba
User        = dba

/Library/ODBC/odbcinst.ini

[ODBC Drivers]
virtuoso-odbc = Installed

[virtuoso-odbc]
Driver = /usr/local/Cellar/virtuoso/7.2.4.2/lib/virtodbc.so

Consequently, even the configuration parameters required to access through Redland has to change.

storage=librdf_new_storage(world, "virtuoso","db1","dsn='VOS',user='dba',password='dba'");

Where VOS is the configuration definition within ODBC. Moreover, the specific ContextNode specifies which is the Named Graph to be used.

jackb
  • 695
  • 8
  • 26
  • 1
    Given the above, I recommend you download and install the [pre-compiled Client Connectivity Kit](http://opldownload.s3.amazonaws.com/uda/virtuoso/7.2/universal-apple-macosx10.7-32/mwvcz2zz.dmg) — which supports both GUI and command-line tools, and is [freely licensed for use against both Open Source and Commercial Edition](http://virtuoso.openlinksw.com/dataspace/doc/dav/wiki/Main/VOSLicense#Client%20Protocol%20Driver%20exemptions%20from%20GPL). DSN configuration through the GUI iODBC Administrator is quite straightforward. – TallTed Sep 12 '16 at 13:51
  • Thanks for the tip. Now that I know how to both configure iODBC and Redland everything is working. – jackb Sep 12 '16 at 13:54
  • 1
    That said, a couple of important odbc.ini lines are incorrect. `VOS = Virtuoso` should be `VOS = virtuoso-odbc`. `Driver = virtuoso-odbc` should be `Driver = /usr/local/Cellar/virtuoso/7.2.4.2/lib/virtodbc.so`. And you're lacking an `[ODBC Drivers]` stanza in `odbcinst.ini` which should have one line, to wit, `virtuoso-odbc = Installed` – TallTed Sep 12 '16 at 13:54
  • Thanks. By the way I'm wondering why, even with the previous configuration, everything seemed to work. – jackb Sep 12 '16 at 13:59
  • Various components are built to be forgiving of many incorrect configs, because so many errors occur in manual configurations in the wild. It's still best to correct those errors, once they're known. – TallTed Sep 12 '16 at 14:04
  • No problem, 'twas just a question out of curiosity (this was my first time with these tools, and hence I am very curious on how the tools I'm using work). I corrected my answer accordingly. – jackb Sep 12 '16 at 14:11
  • P.S. We have lots of available documentation including for [Virtuoso ODBC DSN configuration](http://docs.openlinksw.com/virtuoso/odbcimplementation/) and for [Virtuoso's Provider for Redland](http://virtuoso.openlinksw.com/dataspace/doc/dav/wiki/Main/VirtRDFDriverRedland).... – TallTed Sep 26 '16 at 14:50
1

I don't know much about brew, but is it possible to modify its package-definition so that it renames our isql binary, e.g. to isql-vt instead?

We already do this in our Debian/Ubuntu packaging by calling

./configure     --program-transform-name='s/isql$$/isql-vt/;s/isqlw/isqlw-vt/' 

See https://github.com/openlink/virtuoso-opensource/blob/develop/7/debian/rules#L31

I don't see the error you get from line 941, but two things concerning ODBC connections: 1) your --with-iodbc= must point to a copy of iodbc, not to virtuoso (you can get it from http://iodbc.org/ or your distribution probably has a package e.g. libiodbc2-dev on debian/ubuntu) 2) Virtuoso's isql tests a direct connection to virtuoso; to check that the driver manager is configured properly, use iodbctest (or unixODBC's isql that caused the conflict above in the first place).

Tim Haynes
  • 11
  • 2
  • I'm saying that because in that link there is an odbc version (see the link error above) that is used in Mac as a default library. Hence in that folder there are some libs. Either i put that path or not, i get the same odbc error. – jackb Sep 09 '16 at 16:12
  • If i do the same thing with iodbctest, I get a similar error about the driver, the same one I get from my app. – jackb Sep 09 '16 at 16:17
  • I even tried to link to /usr/lib/iODBC, but I get the same error concerning the driver. I assume Virtuoso has its own drivers in that directory, I edited the odbc's to check if the missing drivers required a specific link in that folder, but nothing good happened. I get the same error anyway. – jackb Sep 09 '16 at 16:33
0

First thing, iODBC is the ODBC driver manager Apple builds into OS X, and users are usually better off sticking with it -- though we (OpenLink Software, maintainers of iODBC) do recommend updating to the curent version, as Apple is typically many updates behind.

Related to that, Apple doesn't bundle the full iODBC SDK. They leave out the Frameworks, among other things.

Generally speaking, UnixODBC doesn't fully integrate with GUI-space OS X apps nor drivers, and there are various other issues that surface over time. Current iODBC doesn't care whether you're working in GUI or command-line, Carbon or Cocoa, 32-bit or 64-bit... It all just works (and if it doesn't work, we want to know, so we can fix it).

MacPorts and other packagers I've used have had ways to switch between UnixODBC and iODBC (e.g., variants); I can't quickly find such for Homebrew, but maybe you can?

TallTed
  • 9,069
  • 2
  • 22
  • 37
  • To be honest, I do not think this is a problem od iODBC/ODBC. It is true that my problem resides in the connection between Redland and Virtuoso, but I have the same issue even on Linux (I ported my code in this platform, and the same issue appears). So at this point it is more a problem of Virtuoso configuration that cannot communicate with ODBC than a problem of ODBC itself. But I'm only making an educated guess... – jackb Sep 09 '16 at 21:38