On Fri, Oct 4, 2024 at 10:56 AM Even Rouault via QGIS-User <
qgis-user@lists.osgeo.org> wrote:

>
> Le 04/10/2024 à 18:06, Andrew Plowright a écrit :
>
> Thanks again Even and Fernando, you've both provided a lot of helpful
> information that has turned this into a very instructive Linux learning
> opportunity.
>
> Even: can I confirm that, in the third option you suggested (the "less
> ugly alternative"), this would involve:
>
> 1. Installing QGIS using Software Manager (or any other way, just not
> necessarily building it from source)
> 2. Building a second instance of GDAL from source which has the same
> version as whatevever GDAL version is created by the QGIS installation
> (ex.: 3.8.4) and which is built with the Mr Sid driver.
> 3. This second instance of GDAL is given its own secluded /opt/gdal_3_8_4
> folder to keep it separate from /usr
> 4. Setting GDAL_DRIVER_PATH will make GDAL search
> /opt/gdal_3_8_4/lib/gdalplugins for additional plugins, such as the MrSid
> driver. This should affect any instance of GDAL, whether I'm running it
> through QGIS or through the command line?
>
> Did I get all that correct?
>
> yes
>
>
> On Sat, Sep 28, 2024 at 10:33 AM Even Rouault <even.roua...@spatialys.com>
> wrote:
>
>> Andrew,
>>
>> $ ldd /bin/qgis.bin | grep gdal
>>
>> libgdal.so.34 => /lib/x86_64-linux-gnu/libgdal.so.34 (0x00007a0581a00000)
>>
>> But I'm not sure what to do with that information.
>>
>> /lib/x86_64-linux-gnu/libgdal.so.34 is the version of GDAL that comes
>> with package manager, so 3.8.4 here
>>
>> I'm not sure how you are familiar with the dynamic linking concepts and
>> tools, but if you're not, reading
>> https://opensource.com/article/22/5/dynamic-linking-modular-libraries-linux
>> or related resources on dynamic linking might help you understand why those
>> seemlingly "weird" behaviors are totally explainable. Takes time, and even
>> with experience, mixing up several versions of a library on a system and
>> being confused is not uncommon
>>
>> I'm going to hate myself for the below suggestion, and you probably too
>> when it will hit you back in the face (so forget I've told you about it
>> ;-),  ... but ... to quickly workaround your issue, you can do:
>>
>> sudo ln -s /usr/lib/libgdal.so.35 /usr/lib/libgdal.so.34        # i'm
>> already hating myself
>>
>> sudo mv /lib/x86_64-linux-gnu/libgdal.so.34
>> /lib/x86_64-linux-gnu/libgdal.so.34.disabled    # I'm hating myself even
>> more...
>>
>> And now launch QGIS.... As GDAL keeps a backwards compatible C ABI, this
>> ugly substitution of the expected GDAL 3.8.4 version at build time is
>> supposed to (mostly) work. That said, you might run in occasional bugs,
>> where QGIS tries to workaround GDAL specific bug, based on the version of
>> GDAL QGIS was built against...
>>
>> OK, I believe you've been sufficienly warned this is *not* the normal way
>> of proceeding, just a quick&dirty workaround
>>
>> To undo the above mess:
>>
>> sudo mv /lib/x86_64-linux-gnu/libgdal.so.34.disabled
>> /lib/x86_64-linux-gnu/libgdal.so.34
>>
>> sudo mv /usr/lib/libgdal.so.34 /usr/lib/libgdal.so.34.disabled  (i'm
>> always nervous doing a rm in /usr territory, so I tend to just rename ...)
>>
>> The clean solution would be that you rebuild QGIS against your installed
>> GDAL, but that would be for another episode. Another friendly advice would
>> be that when doing a custom build you don't do CMAKE_INSTALL_PREFIX=/opt ,
>> but here something like CMAKE_INSTALL_PREFIX=/opt/gdal_3_10_master to avoid
>> messing with /usr which should be only the territory of your package
>> manager tool.
>>
>>
>> Another less ugly alternative would be that you download
>> http://download.osgeo.org/gdal/3.8.4/gdal-3.8.4.tar.gz, build it with
>> support of the MrSID driver as a plugin, with
>> -DGDAL_ENABLE_DRIVER_MRSID_PLUGIN=ON, install it in /opt/gdal_3_8_4, and
>> then just set the GDAL_DRIVER_PATH=/opt/gdal_3_8_4/lib/gdalplugins
>> environment variable. That way you would use the system GDAL library with
>> just the addition of the MrSID driver.
>>
>> Actually that might not be terribly harder to do than my above hacks, so
>> I'm definitely encouraging you to explore that way
>>
>> And ... you should know that the company behind the MrSID SDK has
>> declared they won't ever release any new binary version of it. This means
>> that at most in a few years, this SDK will likely be totally unusable on
>> modern systems. So everyone using SID files had better convert them to
>> something else, like COG, when they still have a chance...
>>
>> /me taking a passport to an undisclosed country without extradition
>> agreement.
>> Even
>>
>> -- http://www.spatialys.com
>> My software is free, but my time generally not.
>>
>> -- http://www.spatialys.com
> My software is free, but my time generally not.
>
> _______________________________________________
> QGIS-User mailing list
> QGIS-User@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>


The way I've been doing it is to build gdal from the Ubuntu distribution
sources rather than the sources from gdal.org. You may need to first enable
sources for apt.
    apt-get source gdal
    cmake \

-DMRSID_ROOT=/opt/MrSID_DSDK-9.5.5.5244-rhel9.x86-64.gcc1131//Raster_DSDK \
        -DCMAKE_BUILD_TYPE=Release ..
No need to set a prefix because the distribution sources will target
/usr/bin/
     cmake --build . -j$(nproc)
Then instead of installing, I move the existing libgdal.so.34.3.8.4 out of
/usr/lib/x86_64-linux-gnu/ and replace it with the one I built. No need to
build QGIS, it now reads MrSID. This approach is minimally disruptive to
your system configuration and easy to bail from.

I do wish MrSID would go away, or at least the publicly funded data wasn't
distributed in proprietary formats.

-- 
Richard W. Greenwood
www.greenwoodmap.com
_______________________________________________
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to