我的目标是让sybase的jodbc驱动程序与我的gradle构建一起工作。但是System/bin64/sa_config.sh
没有按预期工作。此脚本修改/附加DYLD_LIBRARY_PATH
(请参阅脚本提取):
# 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
但找不到lib64
目录中的库。
为了更轻松地检查我尝试了example code from chilkatsoft的情况。 sybase脚本使用的可能性3.我更改了chilkatsoft库的脚本以检查我是否可以加载chilkasoft驱动程序。但是DYLD_LIBRARY_PATH定义不起作用(像-Djava.library.path="path/to/library"
这样的其他选项正在使用这个小例子。)
我添加了一个包含我的测试脚本的子目录myTestDir
,因为总是在根目录下搜索jnilib。这是我的测试脚本:
#!/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
这表示DYLD_LIBRARY_PATH
未添加到java.library.path
,但无效。但直接使用java.library.path
是成功的。见输出:
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
我正在使用当前的Mac OS X版本以及所有更新(10.11.5)。有人有想法让这个工作DYLD_LIBRARY:PATH
??
先谢谢你,Oli