my goal is to make the jodbc driver from sybase working with my gradle build. But the System/bin64/sa_config.sh
is not working as expected. This script modifies/ appends the DYLD_LIBRARY_PATH
(see extraction of script):
# comment the following to unset the SA location.
SQLANY11="/Applications/SQLAnywhere11/System"
export SQLANY11
# comment the following lines to remove SA binaries from your path.
PATH="$SQLANY11/bin64:$SQLANY11/bin32:${PATH:-}"
export PATH
DYLD_LIBRARY_PATH="$SQLANY11/lib32:${DYLD_LIBRARY_PATH:-}"
DYLD_LIBRARY_PATH="$SQLANY11/lib64:${DYLD_LIBRARY_PATH:-}"
export DYLD_LIBRARY_PATH
But the libraries inside the lib64
directories can't be found.
To have a easier check what happenes I tried the example code from chilkatsoft. The sybase script uses the possibility 3. I changed the script of chilkatsoft library to check if I can load the chilkasoft driver. But the DYLD_LIBRARY_PATH definition is not working (other options like -Djava.library.path="path/to/library"
are working with this little example).
I added a subdirectory myTestDir
which includes my test script, because the jnilib is always searched at root directory. This is my test script:
#!/bin/bash
java -version
javac -encoding utf8 -classpath ".:./chilkat.jar" Test.java
BASE_PATH="/Users/Wagner/Desktop/testLIB/chilkatJava-9.5.0-jdk6-macosx/"
echo "################## TEST: with environment variables ########################"
DYLD_LIBRARY_PATH=$BASE_PATH
export DYLD_LIBRARY_PATH
echo "DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH"
java -classpath ".:./chilkat.jar" Test
echo "################## TEST: with absolut path at -Djava.library.path ########################"
java -Djava.library.path=$BASE_PATH -classpath ".:./chilkat.jar" Test
echo "################## TEST: with realative path at -Djava.library.path ########################"
java -Djava.library.path=.. -classpath ".:./chilkat.jar" Test
This shows the DYLD_LIBRARY_PATH
is not added to java.library.path
and it is not working. But using directly the java.library.path
is successful. See output:
myTestDir ./myTest.sh
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
################## TEST: with environment variables ########################
DYLD_LIBRARY_PATH=/Users/Wagner/Desktop/testLIB/chilkatJava-9.5.0-jdk6-macosx/
***** INFOS *****
java.library.path=/Users/Wagner/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
***** LOAD LIBRARY *****
Native code library failed to load.
java.lang.UnsatisfiedLinkError: no chilkat in java.library.path
################## TEST: with absolut path at -Djava.library.path ########################
***** INFOS *****
java.library.path=/Users/Wagner/Desktop/testLIB/chilkatJava-9.5.0-jdk6-macosx/
***** LOAD LIBRARY *****
***** LIBRARY LOADED *****
9.5.0.56
################## TEST: with realative path at -Djava.library.path ########################
***** INFOS *****
java.library.path=..
***** LOAD LIBRARY *****
***** LIBRARY LOADED *****
9.5.0.56
Wagner ... | testLIB | chilkatJava-9.5.0-jdk6-macosx | myTestDir
I'm using the current Mac OS X version with all updates (10.11.5). Do someone have a idea to make this work with DYLD_LIBRARY:PATH
??
Thanks in advance and best regards, Oli