Skip to content

Commit 12e7579

Browse files
authored
Add explicit library search name to allow installation of runtime-only libvips42 on Debian-based systems (#213)
1 parent 464468f commit 12e7579

6 files changed

Lines changed: 42 additions & 30 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repositories {
2323
}
2424

2525
dependencies {
26-
implementation("app.photofox.vips-ffm:vips-ffm-core:1.9.5")
26+
implementation("app.photofox.vips-ffm:vips-ffm-core:1.9.6")
2727
}
2828
```
2929

@@ -171,14 +171,14 @@ You can find them in the [`docker_tests`](docker_tests) folder.
171171

172172
This library requires the `libvips`, `glib`, and `gobject` native libraries to be present in your library path:
173173
* On macOS: `DYLD_LIBRARY_PATH` (installed with `brew install vips`)
174-
* On Linux: `LD_LIBRARY_PATH` (installed with `apt install libvips-dev` on Debian / Ubuntu)
174+
* On Linux: `LD_LIBRARY_PATH` (installed with `apt install libvips42` on Debian / Ubuntu)
175175
* On Windows: `PATH`
176176

177177
The naming conventions of these libraries are not consistent across operating systems, so vips-ffm attempts to load each
178178
in the following order:
179-
* `vips`, `vips.{abiNumber}`, `libvips-{abiNumber}`
180-
* `glib-2.0`, `glib-2.0.{abiNumber}`, `libglib-2.0-{abiNumber}`
181-
* `gobject-2.0`, `gobject-2.0.{abiNumber}`, `libgobject-2.0-{abiNumber}`
179+
* `vips`, `vips.{abiNumber}`, `libvips.so.{abiNumber}`, `libvips-{abiNumber}`
180+
* `glib-2.0`, `glib-2.0.{abiNumber}`, `libglib-2.0.so.{abiNumber}`, `libglib-2.0-{abiNumber}`
181+
* `gobject-2.0`, `gobject-2.0.{abiNumber}`, `libgobject-2.0.so.{abiNumber}`, `libgobject-2.0-{abiNumber}`
182182

183183
Override properties are provided to set your own "ABI number", but note that vips-ffm might not support that version
184184
yet (which could manifest as crashes/segfaults):

core/src/main/java/app/photofox/vipsffm/VipsLibLookup.java

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ private static SymbolLookup findVipsLoader(Arena arena) {
3333
var abiNumber = Optional.ofNullable(System.getProperty("vipsffm.abinumber.vips.override"))
3434
.orElse("42");
3535
var names = List.of(
36-
"vips", // default unix-like
37-
"vips." + abiNumber, // some linux systems don't symlink and need abi number
38-
"libvips-" + abiNumber // windows needs everything
36+
new SymbolLookupSpec("vips", true), // default unix-like
37+
new SymbolLookupSpec("vips." + abiNumber, true), // some linux systems don't symlink and need abi number
38+
new SymbolLookupSpec("libvips.so." + abiNumber, false), // some linux runtime libs use the lib.so.abiNumber format
39+
new SymbolLookupSpec("libvips-" + abiNumber, true) // windows needs everything
3940
);
4041
return findFirstSymbolLookup(arena, names);
4142
}
@@ -48,9 +49,10 @@ private static SymbolLookup findGlibLoader(Arena arena) {
4849
var abiNumber = Optional.ofNullable(System.getProperty("vipsffm.abinumber.glib.override"))
4950
.orElse("0");
5051
var names = List.of(
51-
"glib-2.0", // default unix-like
52-
"glib-2.0." + abiNumber, // some linux systems don't symlink and need abi number
53-
"libglib-2.0-" + abiNumber // windows needs everything
52+
new SymbolLookupSpec("glib-2.0", true), // default unix-like
53+
new SymbolLookupSpec("glib-2.0." + abiNumber, true), // some linux systems don't symlink and need abi number
54+
new SymbolLookupSpec("libglib-2.0.so." + abiNumber, false), // some linux runtime libs use the lib.so.abiNumber format
55+
new SymbolLookupSpec("libglib-2.0-" + abiNumber, true) // windows needs everything
5456
);
5557
return findFirstSymbolLookup(arena, names);
5658
}
@@ -63,30 +65,40 @@ private static SymbolLookup findGObjectLoader(Arena arena) {
6365
var abiNumber = Optional.ofNullable(System.getProperty("vipsffm.abinumber.gobject.override"))
6466
.orElse("0");
6567
var names = List.of(
66-
"gobject-2.0", // default unix-like
67-
"gobject-2.0." + abiNumber, // some linux systems don't symlink and need abi number
68-
"libgobject-2.0-" + abiNumber // windows needs everything
68+
new SymbolLookupSpec("gobject-2.0", true), // default unix-like
69+
new SymbolLookupSpec("gobject-2.0." + abiNumber, true), // some linux systems don't symlink and need abi number
70+
new SymbolLookupSpec("libgobject-2.0.so." + abiNumber, false), // some linux runtime libs use the lib.so.abiNumber format
71+
new SymbolLookupSpec("libgobject-2.0-" + abiNumber, true) // windows needs everything
6972
);
7073
return findFirstSymbolLookup(arena, names);
7174
}
7275

76+
private record SymbolLookupSpec(
77+
String name,
78+
boolean mapToSystemName
79+
) {}
80+
7381
private static SymbolLookup findFirstSymbolLookup(
7482
Arena arena,
75-
List<String> names
83+
List<SymbolLookupSpec> specs
7684
) {
77-
for (var name : names) {
78-
var attempt = attemptLibraryLookup(name, arena);
85+
for (var spec : specs) {
86+
var attempt = attemptLibraryLookup(spec.name, arena, spec.mapToSystemName);
7987
if (attempt.isPresent()) {
8088
return attempt.get();
8189
}
8290
}
8391
return null;
8492
}
8593

86-
static Optional<SymbolLookup> attemptLibraryLookup(String name, Arena arena) {
94+
static Optional<SymbolLookup> attemptLibraryLookup(String name, Arena arena, boolean useSystemNaming) {
95+
var libraryName = name;
96+
if (useSystemNaming) {
97+
libraryName = System.mapLibraryName(libraryName);
98+
}
8799
try {
88100
return Optional.of(
89-
SymbolLookup.libraryLookup(System.mapLibraryName(name), arena)
101+
SymbolLookup.libraryLookup(libraryName, arena)
90102
);
91103
} catch (IllegalArgumentException _) {
92104
return Optional.empty();

docker_tests/debian-12/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ENV PATH="${JAVA_HOME}/bin:${PATH}"
66
COPY sample /opt/sample
77
COPY run_samples.sh /opt/run_samples.sh
88

9-
RUN apt update && apt install --no-install-recommends --yes libvips-dev libvips-tools libjemalloc2
9+
RUN apt update && apt install --no-install-recommends --yes libvips42 libvips-tools libjemalloc2
1010
RUN vips --version
1111

1212
WORKDIR /opt

docker_tests/ubuntu-2404-jemalloc/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ENV PATH="${JAVA_HOME}/bin:${PATH}"
66
COPY sample /opt/sample
77
COPY run_samples.sh /opt/run_samples.sh
88

9-
RUN apt update && apt install --no-install-recommends --yes libvips-dev libvips-tools libjemalloc2
9+
RUN apt update && apt install --no-install-recommends --yes libvips42 libvips-tools libjemalloc2
1010
RUN ln -sT "$(readlink -e /usr/lib/*/libjemalloc.so.2)" /usr/local/lib/libjemalloc.so
1111

1212
RUN vips --version

docker_tests/ubuntu-2404/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ENV PATH="${JAVA_HOME}/bin:${PATH}"
66
COPY sample /opt/sample
77
COPY run_samples.sh /opt/run_samples.sh
88

9-
RUN apt update && apt install --no-install-recommends --yes libvips-dev libvips-tools libjemalloc2
9+
RUN apt update && apt install --no-install-recommends --yes libvips42 libvips-tools libjemalloc2
1010
RUN vips --version
1111

1212
WORKDIR /opt

docs/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,19 @@ <h1 class="title">core API</h1>
5858
<p>Supports a vast range of image formats, including HEIC, JXL, WebP, PNG, JPEG, and more. Pronounced &quot;vips (like zips)
5959
eff-eff-emm&quot;. The project is relatively new, but aims to be production ready. Tested on macOS 14, Windows 11, and Linux
6060
(Ubuntu 24.04, Debian 12.1, with and without jemalloc). Should work on any architecture you can use libvips and
61-
Java on (arm64/amd64/etc).</p>
62-
<p>Uses the &quot;Foreign Function &amp; Memory API&quot; (<a href="https://openjdk.org/jeps/454">JEP 454</a>), and the &quot;Class-File API&quot; (<a href="https://openjdk.org/jeps/457">JEP 457</a>) released in JDK 22.
63-
Built in such a way that it's usually the fastest image processing library available for Java.</p>
61+
Java on (arm64/amd64/etc). Built in such a way that it's usually the fastest image processing library available for Java,
62+
by using the &quot;Foreign Function &amp; Memory API&quot; (<a href="https://openjdk.org/jeps/454">JEP 454</a>) and code generation.</p>
6463
<p>Used the library? I'd love to hear from more users - let me know in <a href="https://github.com/lopcode/vips-ffm/discussions">Discussions</a>. Please also give <a href="https://github.com/lopcode/vips-ffm">the repo</a>
6564
a star 🌟️!</p>
65+
<p>Made in the EU 🇪🇺🇸🇪</p>
6666
<h2 id="usage-heading">Usage</h2>
6767
<p><code>vips-ffm</code> is available on Maven Central. To get set up with Gradle:</p>
6868
<pre><code class="language-kotlin">repositories {
6969
mavenCentral()
7070
}
7171

7272
dependencies {
73-
implementation(&quot;app.photofox.vips-ffm:vips-ffm-core:1.9.5&quot;)
73+
implementation(&quot;app.photofox.vips-ffm:vips-ffm-core:1.9.6&quot;)
7474
}
7575
</code></pre>
7676
<p>Figure out what you're trying to do by looking at the <a href="https://www.libvips.org/API/current/">libvips documentation</a>
@@ -204,15 +204,15 @@ <h2 id="native-library-loading-heading">Native library loading</h2>
204204
<p>This library requires the <code>libvips</code>, <code>glib</code>, and <code>gobject</code> native libraries to be present in your library path:</p>
205205
<ul>
206206
<li>On macOS: <code>DYLD_LIBRARY_PATH</code> (installed with <code>brew install vips</code>)</li>
207-
<li>On Linux: <code>LD_LIBRARY_PATH</code> (installed with <code>apt install libvips-dev</code> on Debian / Ubuntu)</li>
207+
<li>On Linux: <code>LD_LIBRARY_PATH</code> (installed with <code>apt install libvips42</code> on Debian / Ubuntu)</li>
208208
<li>On Windows: <code>PATH</code></li>
209209
</ul>
210210
<p>The naming conventions of these libraries are not consistent across operating systems, so vips-ffm attempts to load each
211211
in the following order:</p>
212212
<ul>
213-
<li><code>vips</code>, <code>vips.{abiNumber}</code>, <code>libvips-{abiNumber}</code></li>
214-
<li><code>glib-2.0</code>, <code>glib-2.0.{abiNumber}</code>, <code>libglib-2.0-{abiNumber}</code></li>
215-
<li><code>gobject-2.0</code>, <code>gobject-2.0.{abiNumber}</code>, <code>libgobject-2.0-{abiNumber}</code></li>
213+
<li><code>vips</code>, <code>vips.{abiNumber}</code>, <code>libvips.so.{abiNumber}</code>, <code>libvips-{abiNumber}</code></li>
214+
<li><code>glib-2.0</code>, <code>glib-2.0.{abiNumber}</code>, <code>libglib-2.0.so.{abiNumber}</code>, <code>libglib-2.0-{abiNumber}</code></li>
215+
<li><code>gobject-2.0</code>, <code>gobject-2.0.{abiNumber}</code>, <code>libgobject-2.0.so.{abiNumber}</code>, <code>libgobject-2.0-{abiNumber}</code></li>
216216
</ul>
217217
<p>Override properties are provided to set your own &quot;ABI number&quot;, but note that vips-ffm might not support that version
218218
yet (which could manifest as crashes/segfaults):</p>

0 commit comments

Comments
 (0)