Packaging GDAL with Java

有些话、适合烂在心里 提交于 2019-12-03 21:21:49

I apologize for not providing a Windows-specific answer, however the concepts between Unix-like and Windows systems here are fundamentally the same. The error you are having is due to the library path (in Windows, still the binary dll) not being part of the required paths. The GDAL config settings don't manage the route to the DLL, but rather locations to internal data.

This may not be the best solution, however this has worked very well for me in the past. The key is to create a script which updates the path required to start the application.

Inside the script, you need to ...

  1. Get the directory of the script itself so you can start the application from anywhere on the system.
  2. Add the path to your library inside the proper environment variable. Use the SCRIPT_PATH as the base of the path.
  3. Update DYLD_LIBRARY_PATH (Mac), LD_LIBRARY_PATH (Linux), and if I remember, PATH (Windows).
  4. Start the application like you exported the library path using the SCRIPT_PATH variable as the base.

Here is an example where I did not set the rpath in clang on my Mac.

  • package

    • bin/foo
    • lib/libtest.dylib
    • run.sh

Run script

#!/bin/sh

#  Get the directory of this script being run
SCRIPT_PATH="`dirname ${BASH_SOURCE[0]}`"

# Export the Path
export DYLD_LIBRARY_PATH=$SCRIPT_PATH/lib:$DYLD_LIBRARY_PATH

#  Run the executable
$SCRIPT_PATH/bin/foo
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!