Context:
I built an a.out
on my local system with a modern CMake project adding a dependency to a shared library:
find_package(GDAL QUIET)
if(GDAL_FOUND)
get_property(_loc TARGET GDAL::GDAL PROPERTY LOCATION)
message(STATUS "Found GDAL: ${_loc} (version ${GDAL_VERSION})")
add_library(gdal_external INTERFACE) # dummy
Everything works fine on my system. Now I want to distribute the a.out
to systems that don't have the dependency (the .so
).
Problem:
I copied the binary a.out
on a cluster, and when I execute it, I get the following error: error while loading shared libraries: libgdal.so.26: cannot open shared object file: No such file or directory
.
Possible solution and other considerations
- Installing the dependencies on the cluster, but I don't have admin rights on this server
- even if I had the dependency installed by the staff, the same problem will arise later when I will ship the binary to possible users
- I can't ask future users to manage dependencies and build from sources.
- It seems to me that I should embed all the dependencies in the same executable, that is using a static library rather than share
- Executable size or memory issues are not the priority
How do I indicate CMake to use the static version of a library ?