<span style=" font-size:10pt;font-family:sans-serif">Hello Robert,</span><br><br><span style=" font-size:10pt;font-family:sans-serif">I've also tried
the problem with libtiff, but couldn't solve it. Thanks for the tip!</span><br><br><span style=" font-size:10pt;font-family:sans-serif">With "gdal[core,tools]"
the apps are now static. </span><br><span style=" font-size:10pt;font-family:sans-serif">BUT I want to
use exactly what is still causing problems: SQLite for the creation of
MBTiles (possibly GPKG) .</span><br><br><span style=" font-size:10pt;font-family:sans-serif">That doesn't seem
to work then :o( ?</span><br><br><span style=" font-size:10pt;font-family:sans-serif">Is there perhaps
still a possibility to use SQLite3 in the static apps if I continue my
first attempt without vcpkg?</span><br><br><span style=" font-size:10pt;font-family:sans-serif">Michael<br></span><br><br><br><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">Von:
</span><span style=" font-size:9pt;font-family:sans-serif">"Robert
Coup" <robert.coup@koordinates.com></span><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">An:
</span><span style=" font-size:9pt;font-family:sans-serif">"Michael
Otto" <michael.otto@data-experts.de></span><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">Kopie:
</span><span style=" font-size:9pt;font-family:sans-serif">dg0yt@darc.de,
gdal-dev@lists.osgeo.org</span><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">Datum:
</span><span style=" font-size:9pt;font-family:sans-serif">20.02.2024
16:26</span><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">Betreff:
</span><span style=" font-size:9pt;font-family:sans-serif">Re:
Re: [gdal-dev] Build static GDAL-Lib and static GDAL-Apps</span><br><hr noshade><br><br><br><span style=" font-size:12pt">Hi,</span><br><br><span style=" font-size:12pt">On Tue, 20 Feb 2024 at 12:50, Michael
Otto <</span><a href="mailto:michael.otto@data-experts.de" target=_blank><span style=" font-size:12pt;color:blue"><u>michael.otto@data-experts.de</u></span></a><span style=" font-size:12pt">>
wrote:</span><br><span style=" font-size:10pt;font-family:sans-serif"><br>I have now tried it with 'vcpkg install gdal[tools]'. The tools/apps are
there, but they are not statically linked!</span><span style=" font-size:12pt"><br></span><span style=" font-size:10pt;font-family:sans-serif"><br>See for example gdalinfo:</span><span style=" font-size:12pt"><br></span><span style=" font-size:10pt;font-family:sans-serif"><br>root@vmuser-VirtualBox:/home/vmuser/Git/vcpkg/installed/x64-linux/tools/gdal#
ldd gdalinfo<br> linux-vdso.so.1 (0x00007ffcc0fb3000)<br> libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
(0x00007fe3a31ae000)<br> libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007fe3a2f82000)<br> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
(0x00007fe3a2d59000)<br> /lib64/ld-linux-x86-64.so.2 (0x00007fe3a6b09000)<br> libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
(0x00007fe3a2d39000)</span><br><br><span style=" font-size:12pt">You're closer! GDAL itself is statically
linked into those executables, as are its dependencies...</span><br><br><span style=" font-size:12pt">So, I did a test, and I think this is
what you need:</span><br><br><tt><span style=" font-size:12pt">$ mkdir custom-triplets</span></tt><br><tt><span style=" font-size:12pt">$ cp vcpkg/triplets/x64-linux.cmake
custom-triplets/x64-linux-static.cmake</span></tt><br><br><span style=" font-size:12pt">(a "triplet" is a vcpkg configuration
for a particular system/cpu/build configuration — linux vs windows vs
android, static vs dynamic, x64 vs arm, etc)</span><br><br><span style=" font-size:12pt">Then edit </span><tt><span style=" font-size:12pt">custom-triplets/x64-linux-static.cmake</span></tt><span style=" font-size:12pt">and change the following to tell it to statically link the system libraries
as well:</span><br><br><tt><span style=" font-size:12pt">- set(VCPKG_CRT_LINKAGE dynamic)</span></tt><br><tt><span style=" font-size:12pt">+ set(VCPKG_CRT_LINKAGE static)</span></tt><br><br><span style=" font-size:12pt">Then build GDAL using your new triplet:</span><br><br><tt><span style=" font-size:12pt">$ vcpkg/vcpkg --overlay-triplets=custom-triplets
--triplet=x64-linux-static install gdal[tools]</span></tt><br><br><span style=" font-size:12pt">But of course it's not quite that simple...
libtiff needs a fix too:</span><br><br><tt><span style=" font-size:12pt">$ mkdir custom-ports</span></tt><br><tt><span style=" font-size:12pt">$ cp -a vcpkg/ports/tiff custom-ports/tiff</span></tt><br><br><span style=" font-size:12pt">Then edit </span><tt><span style=" font-size:12pt">custom-ports/tiff/FindCMath.patch</span></tt><span style=" font-size:12pt;font-family:Arial">and change the following line:</span><br><br><tt><span style=" font-size:12pt">- +find_library(CMath_LIBRARY
NAMES m PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})</span></tt><br><tt><span style=" font-size:12pt">+ +find_library(CMath_LIBRARY
NAMES libm.a m PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})</span></tt><br><br><span style=" font-size:12pt">(this is super-hacky, there will definitely
be a cleaner fix than this, but it works for this purpose right now)</span><br><br><span style=" font-size:12pt">And there's a static linking issue with
something SQLite-plugin-related in GDAL. So lets reduce GDAL to just the
core dependencies and the tools:</span><br><br><tt><span style=" font-size:12pt">$ vcpkg/vcpkg --overlay-triplets=custom-triplets
--triplet=x64-linux-static --overlay-ports=custom-ports install gdal[core,tools]</span></tt><br><tt><span style=" font-size:12pt">... go and play in the sunshine ...</span></tt><br><tt><span style=" font-size:12pt">$ vcpkg/installed/x64-linux-static/tools/gdal/gdalinfo
--version</span></tt><br><tt><span style=" font-size:12pt">GDAL 3.8.3, released 2024/01/04</span></tt><br><tt><span style=" font-size:12pt">$ ldd vcpkg/installed/x64-linux-static/tools/gdal/gdalinfo</span></tt><br><tt><span style=" font-size:12pt">not a dynamic executable</span></tt><br><br><span style=" font-size:12pt">Victory! Now you can hopefully add any
other GDAL features/dependencies via the </span><tt><span style=" font-size:12pt">gdal[core,tools,...]</span></tt><span style=" font-size:12pt">vcpkg feature options. <i>Fully</i> static binaries aren't really a normal
tested output, so you might run into further issues.</span><br><br><span style=" font-size:12pt">Hope that helps,</span><br><br><span style=" font-size:12pt">Rob :)</span><br><br><br><font face="sans-serif"></font>