<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Aptos;}
@font-face
{font-family:"Lucida Sans Unicode";
panose-1:2 11 6 2 3 5 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:12.0pt;
font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.gmailsignatureprefix
{mso-style-name:gmail_signature_prefix;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;
font-weight:normal;
font-style:normal;}
span.EmailStyle21
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;
font-weight:normal;
font-style:normal;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:11.0pt;
mso-ligatures:none;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">I determined in my case that the problem was my build of libsqlite3 which for some reason was missing the SONAME attribute from the binary. This had the effect of the CMAKE
build of GDAL containing the absolute path of libsqlite3 in the libgdal.so file. I thought I’d share the details of how I fixed the issue for my situation in case it will help someone else in the future who searches the archives.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Try this to test whether you are having a similar problem. This was done on my rebuilt libsqlite3 library and the attribute is present as it should be. If it is missing in
yours then that could cause the problem. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">objdump -p libsqlite3.so | grep SONAME<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> SONAME libsqlite3.so.0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">To fix it, I rebuilt my libsqlite3 binary, but you could patch that file to add in the attribute or rebuild it with the correct compiler options to create the attribute. You
could also patch the gdal library after the build.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif">To use patchelf to add a SONAME. ‘patchelf --set-soname libsqlite3.so.3 libsqlite3.so’<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">The line in my Makefile for RHEL8 to build it with the soname looks like this, $(CC) $(CFLAGS) -shared sqlite3.o -Wl,-soname,libsqlite3.so.0 -o $(LIBS)/libsqlite3.so<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">After doing that and rebuilding GDAL the libgdal.so file was as I expected with no absolute path to libsqlite3.so. I preferred to fix the root cause and stored the corrected
libsqlite3 binary in our local repository so that I don’t have to keep patching libgdal after every build.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">ldd libgdal.so | grep libsqlite3<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">libsqlite3.so.0 => /lib64/libsqlite3.so.0 (0x00007fcdab1d7000)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">I’ve no idea why that issue with the libsqlite3 library would affect the cmake build of gdal, but it did.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Shawn Fox<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Andrew Bell <andrew.bell.ia@gmail.com>
<br>
<b>Sent:</b> Wednesday, April 30, 2025 11:59 AM<br>
<b>To:</b> Fox, Shawn D (US) <shawn.fox@baesystems.us><br>
<b>Cc:</b> gdal-dev@lists.osgeo.org<br>
<b>Subject:</b> Re: [gdal-dev] How can I avoid absolute path to shared libraries in libgdal.so<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<table class="MsoNormalTable" border="1" cellspacing="0" cellpadding="0" width="97%" style="width:97.0%;margin-left:5.4pt;border-collapse:collapse;border:none">
<tbody>
<tr style="height:21.2pt">
<td width="97%" valign="top" style="width:97.0%;border:solid red 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:21.2pt">
<p class="MsoNormal" align="center" style="mso-margin-top-alt:auto;margin-bottom:4.0pt;text-align:center;background:white">
<strong><u><span style="font-size:13.5pt;font-family:"Aptos",sans-serif;color:red;mso-ligatures:standardcontextual">External Email Alert</span></u></strong><span style="mso-ligatures:standardcontextual"><o:p></o:p></span></p>
</td>
</tr>
<tr style="height:21.2pt">
<td width="1440" valign="top" style="width:15.0in;border:solid red 1.0pt;border-top:none;padding:0in 5.4pt 0in 5.4pt;height:21.2pt">
<p class="MsoNormal" align="center" style="mso-margin-top-alt:3.0pt;margin-right:0in;margin-bottom:4.0pt;margin-left:0in;text-align:center;background:white">
<strong><span style="font-size:10.0pt;font-family:"Aptos",sans-serif;color:black;mso-ligatures:standardcontextual">This email has been sent from an account outside of the BAE Systems network.</span></strong><span style="mso-ligatures:standardcontextual"><o:p></o:p></span></p>
<p class="MsoNormal" align="center" style="mso-margin-top-alt:auto;margin-bottom:4.0pt;text-align:center">
<span style="font-size:7.5pt;mso-ligatures:standardcontextual">Please treat the email with caution, especially if you are requested to click on a link, decrypt/open an attachment, or enable macros. For further information on how to spot phishing, access “Cybersecurity
OneSpace Page” and report phishing by clicking the button “Report Phishing” on the Outlook toolbar.</span><span style="mso-ligatures:standardcontextual"><o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Shawn,<o:p></o:p></p>
<div>
<p class="MsoNormal"><br>
Without details on your build configuration, it's not going to be easy to figure out what's up. I wouldn't spend time looking at cmake-generated makefiles. cmake works, so if you've having issues, it's because you haven't properly told cmake where to find things
in a way that generates the library in a way that you're happy with. In general, if your dependencies are in some common location, you can just set CMAKE_PREFIX_PATH to that location to tell cmake where to find things, but if your dependencies are in various
places on the system, you may need to add multiple directories or, as your doing, specify each separately. I would advise against using LD_LIBRARY_PATH since it's outside the cmake configuration process (I think).<br>
<br>
That said, you can use a tool like `patchelf` to modify the DT_NEEDED entries of a library in any way you like.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Best,<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Wed, Apr 30, 2025 at 1:43<span style="font-family:"Arial",sans-serif"> </span>PM Fox, Shawn D (US) via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal">Greg, I appreciate the reply, but this is not windows specific. The subject line is referring to libgdal.so which would not be the library name produced on a windows 10 system. I used powershell because I also build GDAL for Windows and
writing powershell commands allows me to write very similar commands across platforms. This problem I've described is only happening on the Linux platform using Red Hat Enterprise Linux version 8. I'm sure a lot of people have opinions about the concept of
rpath vs using LD_LIBRARY_PATH. I'm not interested in discussing that. Our team does have a complicated application build and distribution process, and it isn't useful to try and explain that. The only thing that really matters is that I have to build libgdal.so
with no absolute paths to any dependency baked into libgdal.so, and I'm asking for some help to accomplish that with this new cmake build system. So far I haven't found anything at
<a href="http://gdal.org" target="_blank">gdal.org</a> that helps to explain the behavior I'm obser<br>
ving, and the generated build files are awfully difficult to read. So if anyone has had similar issues since the build system changed to cmake or has any advice on how to read through the generated build files to find the commands being used for linking I'd
appreciate any tips. At this point I'm using grep on the build output to search for clues, and I haven't found any yet.<br>
<br>
Evidently, the -DSQLite3_LIBRARY="$SQLITE_LIB" has to have the full path to the library file in the variable, otherwise a build failure occurs. Yet if I put the full path into it as required then the GDAL build system bakes it into libgdal.so. That behavior
does not occur for any other dependency. My guess is that the build system is generating the dash upper and lower case linker options differently for sqlite but I can't figure out why or what I need to do to manipulate it to generate what I need.<br>
<br>
I set up the cmake commands using examples from the website and then read the build instructions to set the paths to all dependencies that I need just as the instructions state that I should. According to it, there are specific variables for each plugin that
have to be set in the cmake command to generate the build system so my cmake command sare modeled with those instructions.<br>
<a href="https://gdal.org/en/stable/development/building_from_source.html" target="_blank">https://gdal.org/en/stable/development/building_from_source.html</a><br>
<br>
The GDAL build will not succeed for me on RHEL8 without specifying all of the library paths within LD_LIBRARY_PATH, and that is in addition to putting the full path into all of the variables used in the first cmake command to generate the build system. It
seems to be necessary in order for the linking to succeed. <br>
<br>
Thanks<br>
<br>
-----Original Message-----<br>
From: gdal-dev <<a href="mailto:gdal-dev-bounces@lists.osgeo.org" target="_blank">gdal-dev-bounces@lists.osgeo.org</a>> On Behalf Of Greg Troxel via gdal-dev<br>
Sent: Tuesday, April 29, 2025 4:23 PM<br>
To: Fox, Shawn D (US) via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>><br>
Subject: Re: [gdal-dev] How can I avoid absolute path to shared libraries in libgdal.so<br>
<br>
External Email Alert<br>
<br>
This email has been sent from an account outside of the BAE Systems network.<br>
<br>
Please treat the email with caution, especially if you are requested to click on a link, decrypt/open an attachment, or enable macros. For further information on how to spot phishing, access "Cybersecurity OneSpace Page" and report phishing by clicking the
button "Report Phishing" on the Outlook toolbar.<br>
<br>
<br>
"Fox, Shawn D (US) via gdal-dev" <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>> writes:<br>
<br>
> ldd libgdal.so<br>
> linux-vdso.so.1 (0x00007ffe0e3f7000)<br>
> libdl.so.2 => /lib64/libdl.so.2 (0x00007feaca6a6000)<br>
> libcurl.so.4 => /lib64/libcurl.so.4 (0x00007feaca417000)<br>
> libproj.so.22 => not found<br>
> libexpat.so.1 => /lib64/libexpat.so.1 (0x00007feaca1db000)<br>
> <a href="http://libxerces-c-3.1.so" target="_blank">libxerces-c-3.1.so</a> => not found<br>
> <br>
> /data/third_party_unzip/exp/SQLite/SQLite-3.23.1/lib/libsqlite3.so => <br>
> not found<br>
<br>
[incorrect line wrapping fixed]<br>
<br>
I am puzzled by your approach and problems. Normally you would either<br>
expect<br>
<br>
dependencies to be provided by a packaging system (such as a<br>
"distribution"), and then expect to have to have that set of packages<br>
installed, resulting in the same files at the same paths<br>
<br>
or<br>
<br>
construct your own packaging where you build those deps first and then<br>
gdal, to some prefix<br>
<br>
<br>
but it seems like you have built gdal on one system and are trying to run it on a system with different contents.<br>
<br>
> Notice that the only absolute path is for sqlite3. I had to specify<br>
<br>
That is odd. I'd expect that this is the result of<br>
<br>
-l/data/third_party_unzip/exp/SQLite/SQLite-3.23.1/lib/libsqlite3.so<br>
<br>
being passed tot he linker.<br>
<br>
> the full path to all dependencies but only the full path to sqlite is <br>
> embedded into the .so file. This is a major problem since now GDAL <br>
> will not load at run-time unless libsqlite exists on the system at <br>
> that exact location. I'm supplying absolute paths to the location of <br>
> all dependencies in the cmake command to generate the build directory. <br>
> Does anyone know why sqlite would be linked differently? So far I'm <br>
> searching through the build directory for references but I haven't <br>
> found a reason or the behavior yet. The build instructions at <br>
> <a href="http://gdal.org" target="_blank">gdal.org</a> seem straightforward so I don't see anything on that site
<br>
> that explains the behavior. I'm guessing it relates to how the build <br>
> files are generated by the gdal build system. I don't want the <br>
> absolute path to anything baked into libgdal.so.<br>
<br>
Generally one needs -L and -R for the dirs that have the libs, and -l for libnames.<br>
<br>
> My Cmake command to generate the build looks like this, and I'm also <br>
> putting path to all dependencies into LD_LIBRARY_PATH first. I didn't <br>
> think it would help to show all of the paths since they'd be different <br>
> on other Linux systems. Bases on this I'm failing to understand why <br>
> the dependencies are not linked in consistently. I'm building GDAL <br>
> using powershell commands.<br>
><br>
> $Env:LD_LIBRARY_PATH="${CURL_LIB_DIR}:${SQLITE_LIB_DIR}:${EXPAT_LIB_DIR}:${PROJ_LIB_DIR}:${XERCES_LIB_DIR}:${OPENSSL_LIB_DIR}:${Env:LD_LIBRARY_PATH}"<br>
<br>
I don't think it's good to use LD_LIBRARY_PATH. That's working around -L/-R not being correct.<br>
<br>
> cmake -S . -B ../build/$CONFIGL -DCMAKE_INSTALL_PREFIX="../install/$CONFIGL" -DCMAKE_BUILD_TYPE="$CONFIG" `<br>
> -DGDAL_USE_OPENSSL=OFF -DGDAL_USE_EXTERNAL_LIBS:BOOL=OFF `<br>
> -DOPENSSL_ROOT_DIR="$OPENSSL_ROOT_DIR" `<br>
> -DPROJ_INCLUDE_DIR="$PROJ_INCLUDE" -DPROJ_LIBRARY_RELEASE="$PROJ_LIB" `<br>
> -DGDAL_USE_CURL=ON -DCURL_INCLUDE_DIR="$CURL_INCLUDE" -DCURL_LIBRARY_RELEASE="$CURL_LIB" `<br>
> -DGDAL_USE_XERCESC=ON -DXercesC_INCLUDE_DIR="$XERCES_INCLUDE" -DXercesC_LIBRARY="$XERCES_LIB" `<br>
> -DGDAL_USE_EXPAT=ON -DEXPAT_INCLUDE_DIR="$EXPAT_INCLUDE" -DEXPAT_LIBRARY="$EXPAT_LIB" `<br>
> -DGDAL_USE_SQLITE3=ON -DSQLite3_INCLUDE_DIR="$SQLITE_INCLUDE" -DSQLite3_LIBRARY="$SQLITE_LIB" `<br>
> -DACCEPT_MISSING_SQLITE3_MUTEX_ALLOC:BOOL=ON -DACCEPT_MISSING_SQLITE3_RTREE:BOOL=ON `<br>
> 2>&1 | tee cmake_configure_${PLATFORM}_${TOOLSET}_${CONFIGL}.txt<br>
<br>
I find that cmake tends to hide the actual build lines by default, and that one needs to remediate this with some kind of verbose option, and then you can see what the values of cmake variables are and what the actual compiler/linker flags are.<br>
<br>
It could be that you are running into Windows-specific trouble, about which I know very little.<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></p>
</blockquote>
</div>
<div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><span class="gmailsignatureprefix">-- </span><o:p></o:p></p>
<p class="MsoNormal">Andrew Bell<br>
<a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a><o:p></o:p></p>
</div>
</body>
</html>