Skip to content

Commit

Permalink
fix: use dylib extension instead of jnilib for MacOS library names
Browse files Browse the repository at this point in the history
  • Loading branch information
kkriske authored Jul 24, 2023
1 parent 3ffef4d commit 78defd0
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- '**.java'
- '**.xml'
- '**.so'
- '**.jnilib'
- '**.dylib'
- '**.dll'
- '.github/workflows/*.yml'
push:
Expand All @@ -22,7 +22,7 @@ on:
- '**.java'
- '**.xml'
- '**.so'
- '**.jnilib'
- '**.dylib'
- '**.dll'
- '.github/workflows/*.yml'

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ sparcv9:
$(MAKE) native OS_NAME=SunOS OS_ARCH=sparcv9

mac64-signed: mac64
$(CODESIGN) src/main/resources/org/sqlite/native/Mac/x86_64/libsqlitejdbc.jnilib
$(CODESIGN) src/main/resources/org/sqlite/native/Mac/x86_64/libsqlitejdbc.dylib

mac-arm64-signed: mac-arm64
$(CODESIGN) src/main/resources/org/sqlite/native/Mac/aarch64/libsqlitejdbc.jnilib
$(CODESIGN) src/main/resources/org/sqlite/native/Mac/aarch64/libsqlitejdbc.dylib

package: native-all
rm -rf target/dependency-maven-plugin-markers
Expand Down
6 changes: 3 additions & 3 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Mac-x86_CC := gcc
Mac-x86_STRIP := strip -x
Mac-x86_CCFLAGS := -I$(JAVA_HOME)/include -Ilib/inc_mac -Os -fPIC -mmacosx-version-min=10.4 -fvisibility=hidden
Mac-x86_LINKFLAGS := -dynamiclib
Mac-x86_LIBNAME := libsqlitejdbc.jnilib
Mac-x86_LIBNAME := libsqlitejdbc.dylib
Mac-x86_SQLITE_FLAGS := -DSQLITE_ENABLE_LOCKING_STYLE=0

HPUX-ia64_32_CC := cc
Expand All @@ -201,7 +201,7 @@ ifeq ($(wildcard MAC_SDK),)
endif
Mac-x86_64_CCFLAGS := -I$(MAC_SDK)/System/Library/Frameworks/JavaVM.framework/Headers -Ilib/inc_mac -Os -fPIC -mmacosx-version-min=10.6 -fvisibility=hidden -Wno-implicit-function-declaration
Mac-x86_64_LINKFLAGS := -dynamiclib
Mac-x86_64_LIBNAME := libsqlitejdbc.jnilib
Mac-x86_64_LIBNAME := libsqlitejdbc.dylib
Mac-x86_64_SQLITE_FLAGS :=

# Use a CROSS_PREFIX as the cross-triple clang is not available in crossbuild, see https://github.com/multiarch/crossbuild/blob/ad79cc84b6fb3fb1d09bc4a78719ef26f23bab85/Dockerfile#L134
Expand All @@ -211,7 +211,7 @@ Mac-aarch64_STRIP := $(CROSS_PREFIX)strip -x
MAC_SDK := /usr/osxcross/SDK/MacOSX11.3.sdk
Mac-aarch64_CCFLAGS := -I$(MAC_SDK)/System/Library/Frameworks/JavaVM.framework/Headers -Ilib/inc_mac -Os -fPIC -mmacosx-version-min=10.9 -fvisibility=hidden -Wno-implicit-function-declaration
Mac-aarch64_LINKFLAGS := -dynamiclib
Mac-aarch64_LIBNAME := libsqlitejdbc.jnilib
Mac-aarch64_LIBNAME := libsqlitejdbc.dylib
Mac-aarch64_SQLITE_FLAGS :=

Windows-x86_CC := $(CROSS_PREFIX)gcc
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ id = 2
== How does SQLiteJDBC work?

Our SQLite JDBC driver package (i.e., `sqlite-jdbc-{project-version}.jar`) contains three
types of native SQLite libraries (`sqlitejdbc.dll`, `sqlitejdbc.jnilib`, `sqlitejdbc.so`),
types of native SQLite libraries (`sqlitejdbc.dll`, `sqlitejdbc.dylib`, `sqlitejdbc.so`),
each of them is compiled for Windows, macOS and Linux. An appropriate native library
file is automatically extracted into your OS's temporary folder, when your program
loads `org.sqlite.JDBC` driver.
Expand Down
12 changes: 6 additions & 6 deletions SQLiteJDBC.wiki
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Our SQLiteJDBC library, developed as a part of [http://www.xerial.org Xerial pro

The original Zentus's SQLite JDBC driver http://www.zentus.com/sqlitejdbc/ itself is an excellent utility for using [https://www.sqlite.org SQLite] databases from Java language, and our SQLiteJDBC library also relies on its implementation. However, its pure-java version, which totally translates c/c++ codes of SQLite into Java, is significantly slower compared to its native version, which uses SQLite binaries compiled for each OS (win, mac, linux).

To use the native version of sqlite-jdbc, user had to set a path to the native codes (dll, jnilib, so files, which are JNDI C programs) by using command-line arguments, e.g., -Djava.library.path=(path to the dll, jnilib, etc.), or -Dorg.sqlite.lib.path, etc. This process was error-prone and bothersome to tell every user to set these variables. Our SQLiteJDBC library completely does away these inconveniences.
To use the native version of sqlite-jdbc, user had to set a path to the native codes (dll, dylib, so files, which are JNDI C programs) by using command-line arguments, e.g., -Djava.library.path=(path to the dll, dylib, etc.), or -Dorg.sqlite.lib.path, etc. This process was error-prone and bothersome to tell every user to set these variables. Our SQLiteJDBC library completely does away these inconveniences.

Another difference is that we are keeping this SQLiteJDBC libray up-to-date to the newest version of SQLite engine, because we are one of the hottest users of this library. For example, SQLite JDBC is a core component of [http://utgenome.org/ UTGB (University of Tokyo Genome Browser) Toolkit], which is our utility to create personalized genome browsers.

Expand Down Expand Up @@ -254,7 +254,7 @@ Another sample code is [http://code.google.com/p/xerial/source/browse/src/test/j

== How does SQLiteJDBC work? ==

Our SQLite JDBC driver package (i.e., sqlite-jdbc-(VERSION).jar) contains three types of native SQLite libraries (sqlite-jdbc.dll, sqlite-jdbc.jnilib, sqlite-jdbc.so), each of them is compiled for Windows, Mac OS and Linux. An appropriate native library file is automatically extracted into your OS's temporary folder, when your program loads "org.sqlite.JDBC" driver.
Our SQLite JDBC driver package (i.e., sqlite-jdbc-(VERSION).jar) contains three types of native SQLite libraries (sqlite-jdbc.dll, sqlite-jdbc.dylib, sqlite-jdbc.so), each of them is compiled for Windows, Mac OS and Linux. An appropriate native library file is automatically extracted into your OS's temporary folder, when your program loads "org.sqlite.JDBC" driver.

== Source Codes ==
* Mercurial Repository: http://code.google.com/p/xerial/source/checkout?repo=sqlite
Expand Down Expand Up @@ -308,7 +308,7 @@ If you are familier with [http://maven.apache.org Maven2], add the following XML
== Using SQLiteJDBC with Tomcat6 Web Server ==
Do not include sqlite-jdbc-(version).jar in WEB-INF/lib folder of your web application package, since multiple web applications hosted by the same Tomcat server cannot load the sqlite-jdbc native library more than once. That is the specification of JNI (Java Native Interface). You will observe UnsatisfiedLinkError exception with the message "no SQLite library found".

Work-around of this problem is to put sqlite-jdbc-(version).jar file into (TOMCAT_HOME)/lib direcotry, in which multiple web applications can share the same native library file (.dll, .jnilib, .so) extracted from this sqlite-jdbc jar file.
Work-around of this problem is to put sqlite-jdbc-(version).jar file into (TOMCAT_HOME)/lib directory, in which multiple web applications can share the same native library file (.dll, .dylib, .so) extracted from this sqlite-jdbc jar file.

If you are using Maven for your web application, set the dependency scope as 'provided', and manually put the SQLite JDBC jar file into (TOMCAT_HOME)/lib folder.
{{{
Expand Down Expand Up @@ -360,9 +360,9 @@ export PATH=$MAVEN_HOME/bin:$PATH
* Mac OS X (10.4.10 Tiger ~ 10.5 Leopard)
* dependency check
{{{
> otool -L libsqlitejdbc.jnilib
libsqlitejdbc.jnilib:
build/Darwin-i386/libsqlitejdbc.jnilib (compatibility version 0.0.0, current version 0.0.0)
> otool -L libsqlitejdbc.dylib
libsqlitejdbc.dylib:
build/Darwin-i386/libsqlitejdbc.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.9)
}}}
* Linux (glibc-2.5.12)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sqlite/SQLiteJDBCLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

/**
* Set the system properties, org.sqlite.lib.path, org.sqlite.lib.name, appropriately so that the
* SQLite JDBC driver can find *.dll, *.jnilib and *.so files, according to the current OS (win,
* SQLite JDBC driver can find *.dll, *.dylib and *.so files, according to the current OS (win,
* linux, mac).
*
* <p>The library files are automatically extracted from this project's package (JAR).
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/org/sqlite/util/LibraryLoaderUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ public static String getNativeLibResourcePath() {

/** Get the OS-specific name of the sqlitejdbc native library. */
public static String getNativeLibName() {
String nativeLibName = System.mapLibraryName("sqlitejdbc");
if (nativeLibName != null && nativeLibName.endsWith(".dylib")) {
nativeLibName = nativeLibName.replace(".dylib", ".jnilib");
}
return nativeLibName;
return System.mapLibraryName("sqlitejdbc");
}

public static boolean hasNativeLib(String path, String libraryName) {
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 78defd0

Please sign in to comment.