Skip to content

Commit b1a4aa0

Browse files
authored
Added extra rpath entries to common macOS library install locations. (#95)
1 parent fd27b0c commit b1a4aa0

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ jobs:
6969
if: steps.conda-cache.outputs.cache-hit != 'true'
7070
run: conda install pdal=${{ matrix.pdal }}
7171

72-
- name: Set LD_LIBRARY_PATH
72+
- name: Set LD_LIBRARY_PATH
73+
if: ${{ matrix.os == 'ubuntu-latest' }}
7374
run: echo "LD_LIBRARY_PATH=$CONDA/envs/pdal-java/lib:/usr/local/lib:$LD_LIBRARY_PATH" >> "$GITHUB_ENV"
7475

7576
- name: Check formatting
@@ -137,7 +138,8 @@ jobs:
137138
if: steps.conda-cache.outputs.cache-hit != 'true'
138139
run: conda install pdal=${{ matrix.pdal }}
139140

140-
- name: Set LD_LIBRARY_PATH
141+
- name: Set LD_LIBRARY_PATH
142+
if: ${{ matrix.os == 'ubuntu-latest' }}
141143
run: echo "LD_LIBRARY_PATH=$CONDA/envs/pdal-java/lib:/usr/local/lib:$LD_LIBRARY_PATH" >> "$GITHUB_ENV"
142144

143145
- uses: actions/download-artifact@v4

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![CI](https://github.com/PDAL/java/workflows/CI/badge.svg)](https://github.com/PDAL/java/actions) [![Join the chat at https://gitter.im/PDAL/PDAL](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/PDAL/PDAL?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Maven Central](https://img.shields.io/maven-central/v/io.pdal/pdal_2.13)](https://search.maven.org/search?q=g:io.pdal) [![Snapshots](https://img.shields.io/nexus/s/https/oss.sonatype.org/io.pdal/pdal_2.13)](https://oss.sonatype.org/content/repositories/snapshots/io/pdal/)
44

55

6-
Java bindings to use PDAL on JVM (supports PDAL >= 2.0). Mac users can experience some issues with bindings that were build against a different PDAL version, so try to use a consistent PDAL version.
6+
Java bindings to use PDAL on JVM (supports PDAL >= 2.0). macOS users can experience some issues with bindings that were build against a different PDAL version, so try to use a consistent PDAL version.
77

88
It is released independently from PDAL itself as of PDAL 1.7.
99

@@ -45,7 +45,7 @@ libraryDependencies ++= Seq(
4545
If you would like to use your own bindings, it is necessary to set `java.library.path`:
4646

4747
```scala
48-
// Mac OS X example with manual JNI installation
48+
// macOS X example with manual JNI installation
4949
// cp -f native/target/resource_managed/main/native/x86_64-darwin/libpdaljni.2.1.dylib /usr/local/lib/libpdaljni.2.1.dylib
5050
// place built binary into /usr/local/lib, and pass java.library.path to your JVM
5151
javaOptions += "-Djava.library.path=/usr/local/lib"
@@ -224,9 +224,8 @@ Development purposes (including binaries) compilation:
224224
3. Build native libs `sbt native/nativeCompile` (optionally, binaries would be built during tests run) or `sbt native/publishLocal` for the built jar only
225225
4. Run `sbt core/test` to run PDAL tests
226226

227-
228227
Only Java development purposes compilation:
229-
1. Provide `$LD_LIBRARY_PATH` or `$DYLD_LIBRARY_PATH`
228+
1. Provide `$LD_LIBRARY_PATH` or `$DYLD_FALLBACK_LIBRARY_PATH`
230229
2. If you don't want to provide global variable you can pass `-Djava.library.path=<path>` into sbt:
231230
`./sbt -Djava.library.path=<path>`
232231
3. Set `PDAL_DEPEND_ON_NATIVE=false` (to disable `native` project build)
@@ -259,7 +258,7 @@ the quick workaround would be to replace [this](./java/native/src/CMakeLists.txt
259258
set(CMAKE_CXX_FLAGS "-L<path to dynamic libs> -std=c++11")
260259
```
261260

262-
#### - On mac os could be difficult to install PDAL sometimes (near new releases). You have three options
261+
#### - On macOS could be difficult to install PDAL sometimes (near new releases). You have three options
263262
- ##### Install PDAL with conda
264263
Here the [PDAL conda guide](https://pdal.io/en/2.6.0/workshop/conda.html)
265264

@@ -269,6 +268,16 @@ set(CMAKE_CXX_FLAGS "-L<path to dynamic libs> -std=c++11")
269268
- ##### Build PDAL from sources
270269
Follow the [official guide](https://pdal.io/en/latest/development/compilation/index.html#compilation)
271270

271+
#### - When using the Maven Central JARs on macOS, I get `Library not loaded: @rpath/libpdalcpp.16.dylib` error
272+
273+
If you are sure PDAL is correctly installed, you can run `pdal-config --libs` and take the path after the `-L` argument
274+
and assign it to the `DYLD_FALLBACK_LIBRARY_PATH`:
275+
276+
❯ pdal-config --libs
277+
-L/opt/homebrew/Cellar/pdal/2.6.3/lib -lpdalcpp
278+
❯ export DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/Cellar/pdal/2.6.3/lib
279+
❯ java -jar my-pdal-proj.jar
280+
272281
## How To Release
273282
All the instructions related to the local / maven release process are documented in the [HOWTORELEASE.txt](./HOWTORELEASE.txt) file.
274283

native/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ if (APPLE)
1919
SET(CMAKE_SKIP_BUILD_RPATH TRUE)
2020
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
2121
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
22+
set(CMAKE_INSTALL_RPATH "@rpath:/usr/local/lib:/opt/homebrew/lib:/opt/local/lib")
2223
endif ()
2324

2425
if (NOT PDAL_BUILD)

0 commit comments

Comments
 (0)