CQLdriver.jl
CQLdriver.jl copied to clipboard
Error: could not load library "libcassandra.so.2"
Looks like the driver is looking for a shared object file from libcassandra
, which does not seem to be present at any of the usual locations.
julia> session, cluster, err = cqlinit("foo, bar, baz")
ERROR: could not load library "libcassandra.so.2"
dlopen(libcassandra.so.2.dylib, 0x0001): tried: '/Applications/Julia-1.7.app/Contents/Resources/julia/lib/julia/libcassandra.so.2.dylib' (no such file), '/Applications/Julia-1.7.app/Contents/Resources/julia/bin/../lib/libcassandra.so.2.dylib' (no such file), 'libcassandra.so.2.dylib' (no such file), '/usr/local/lib/libcassandra.so.2.dylib' (no such file), '/usr/lib/libcassandra.so.2.dylib' (no such file)
Stacktrace:
[1] cql_cluster_new
@ ~/.julia/packages/CQLdriver/4R8iQ/src/cqlwrapper.jl:107 [inlined]
[2] cqlinit(hosts::String; username::String, password::String, whitelist::String, blacklist::String, threads::Int64, connections::Int64, queuesize::Int64, bytelimit::Int64, requestlimit::Int64)
@ CQLdriver ~/.julia/packages/CQLdriver/4R8iQ/src/CQLdriver.jl:55
[3] cqlinit(hosts::String)
@ CQLdriver ~/.julia/packages/CQLdriver/4R8iQ/src/CQLdriver.jl:55
[4] top-level scope
@ REPL[2]:1
I verified my cassandra installation is correct and even tried installing the C++ drivers that this library seems to be based on:
$ brew info cassandra
cassandra: stable 4.0.5 (bottled)
Eventually consistent, distributed key-value store
https://cassandra.apache.org
/opt/homebrew/Cellar/cassandra/4.0.5 (1,168 files, 70.5MB) *
Poured from bottle on 2022-08-01 at 14:22:30
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/cassandra.rb
License: Apache-2.0
==> Dependencies
Build: libcython ✔
Required: openjdk@11 ✔, [email protected] ✔, six ✔
==> Caveats
To restart cassandra after an upgrade:
brew services restart cassandra
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/cassandra/bin/cassandra -f
==> Analytics
install: 2,862 (30 days), 8,196 (90 days), 27,313 (365 days)
install-on-request: 2,860 (30 days), 8,191 (90 days), 27,301 (365 days)
build-error: 0 (30 days)
$ brew info cassandra-cpp-driver
cassandra-cpp-driver: stable 2.16.2 (bottled), HEAD
DataStax C/C++ Driver for Apache Cassandra
https://docs.datastax.com/en/developer/cpp-driver/latest
/opt/homebrew/Cellar/cassandra-cpp-driver/2.16.2 (10 files, 2.5MB) *
Poured from bottle on 2022-08-02 at 10:31:25
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/cassandra-cpp-driver.rb
License: Apache-2.0
==> Dependencies
Build: cmake ✔
Required: libuv ✔, [email protected] ✔
==> Options
--HEAD
Install HEAD version
==> Analytics
install: 29 (30 days), 56 (90 days), 209 (365 days)
install-on-request: 29 (30 days), 56 (90 days), 209 (365 days)
build-error: 2 (30 days)
It seems to me that I might simply be missing a symlink to the shared object or that Julia is just looking for it in the wrong places because the Cassandra drivers seem to work fine with cqlsh
or with Python on my computer. Any idea where I can find the missing file or if I am missing a dependency for this library?
I have had some trouble with getting the driver set up, too. This workaround succeeds in a debian-based Dockerfile, and something similar worked on my Manjaro linux laptop. Hopefully you can adapt this to your needs!
FROM julia:1.7-bullseye
# Install Datastax Cassandra C++ driver.
RUN apt-get update && apt-get install -y libuv1 binutils xz-utils && rm -rf /var/lib/apt/lists/*
# Hacky/manual approach that gets around flakey checks for `multiarch-support`.
RUN mkdir /tmp/cassandra \
&& curl -L -o /tmp/cassandra/driver.deb https://downloads.datastax.com/cpp-driver/ubuntu/18.04/cassandra/v2.16.0/cassandra-cpp-driver_2.16.0-1_amd64.deb \
&& cd /tmp/cassandra \
&& ar x driver.deb \
&& tar -xf data.tar.xz --directory / \
&& ln -s /usr/lib/x86_64-linux-gnu/libcassandra.so.2.16.0 /usr/lib/libcassandra.so.2 \
&& rm -rf /tmp/cassandra
The .so file needs to be indexed by your Linux system as seen by ldconfig
, so that's the key. It might be that a Python environment manages paths on its own. Usually files in /lib and /usr/lib are indexed automatically, but if you have shared libraries in other directories, then you can make them permanently visible by adding them to /etc/ld.so.conf
I'm sorry, I should have clarified that I am running this on an M1 MacBook Pro. I currently have the following LDFLAGS
set:
-L/opt/homebrew/opt/cassandra-cpp-driver/lib -L/opt/homebrew/opt/freetds/lib -L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/opt/xz/lib
The problem is that /opt/homebrew/opt/cassandra-cpp-driver/lib
on Mac doesn't seem to contain a .so
file at all.
$ ls /opt/homebrew/opt/cassandra-cpp-driver/lib/
libcassandra.2.16.2.dylib libcassandra.2.dylib libcassandra.dylib
@aryan-jain I don't know enough about dynamic linking to generalize this driver to run with the Mac files, but I'll happily review a PR if you open one.