gdal icon indicating copy to clipboard operation
gdal copied to clipboard

Provide a `bundled` feature

Open weiznich opened this issue 2 years ago • 6 comments

This is mostly a feature request. Many *-sys crates provide a bundled or vendored feature that builds and links static version of the corresponding C dependency as part of the build process. It would be great if gdal would provide a similar feature as well.

The main motivation for such a feature is that it would greatly simplify setting up the development/deploy environment as everything would be build as part of the build process.

weiznich avatar Nov 15 '23 07:11 weiznich

I'm not sure how feasible this is. GDAL can link to dozens of external libraries, and I don't think it reliably auto-detects all of them (haven't played much with the new CMake-based build system, though). Even if detection worked, you'd still have to install other libraries.

proj-sys managed to make it work, but it still depends on SQLite, libtiff and probably even cURL.

lnicola avatar Nov 16 '23 14:11 lnicola

I'm aware that gdal itself has quite a lot of external dependencies, as I've a local setup that statically links gdal anyway. What we do there is to disable as many of the external dependencies as possible. That's feasible for us as we don't require much of the optional functionality anyway.

For SQLlite it should be as simple as optionally including the libsqlite3-sys crate with the "bundled" feature behind a feature flag.

If bundling support is something that would be acceptable for the gdal crate as well I might give it a try someday and open a PR if that is successful.

weiznich avatar Nov 27 '23 16:11 weiznich

I think it would be nice to have, but I don't know how configuring it would ideally work. E.g. I'd find it sweet if I could build GDAL from source, but with the system SQLite.

lnicola avatar Nov 27 '23 16:11 lnicola

We build GDAL from scratch all the time (we license the JPKAK driver). The new cmake system is much much better, particularly given it has a principled way of allowing you to override paths, settings, etc.

One thing I've never been able to do is statically link GDAL into Rust code. @weiznich Any tips/tricks you can share?

metasim avatar Dec 19 '23 20:12 metasim

IIRC static linking worked for me in the past, but I can't easily try it on my current distro because of a package (libgta) that's missing a static library.

lnicola avatar Dec 19 '23 20:12 lnicola

I've opened #517 That builds a more or less minimal version of gdal during cargo build. proj seems to be the only required external dependency, and there we can just use proj-sys + the bundled feature there to get a in tree build + static linking.

weiznich avatar Jan 26 '24 07:01 weiznich