0

I have built GDAL 3.7.0 with vcpkg, creating ..\Documents\vcpkg\installed\x86-windows\lib\gdal.lib (I make a .lib to statically link into my C++ application). It is my understanding that when vcpkg builds gdal.lib it links in static versions of the various driver code to read the various formats supported by GDAL. This corresponds to what I see in my application: It can open TIFF and JP2 files, even though there are no DLLs in the "plugins" directory that I provide to GDAL in the call CPLSetConfigOption( "GDAL_DRIVER_PATH", "my/path/to/plugins" ).

My understanding is that certain proprietary formats cannot be read by GDAL without some code provided by the format owner. I have downloaded the appropriate Windows DSDK from https://www.extensis.com/support/developers. Inside the SDK is the folder lib, which contains lti_dsdk.lib, lti_dsdk_9.5.dll, lti_dsdk_cdll.lib, lti_dsdk_cdll_9.5.dll, and tbb.dll. I have put all of these files in my plugins directory, run my program, and it still can't read .sid files.

I don't know if I need to provide the DSDK directory to vcpkg earlier in the process, during the GDAL build. I have looked at vcpkg\ports\gdal\vcpkg.json and it's not clear to me which feature/configuration I would use to specify the location of the DSDK.

Can you help me understand the specifics to enable .sid reading, either (a) the way I need to provide DLLs to my program at runtime, or (b) the way I need to build GDAL differently with vcpkg?

1
  • 1
    GDAL must be built with MrSID support, and in addition the MrSID binaries must be available. In GDAL it is possible to build drivers internally, or as plugins. So the plugin directory may be empty but a driver may still work. Usually proprietary drivers are built as plugins because then the end user may activate and deactivate them easier.
    – user30184
    Commented Jul 8, 2023 at 21:21

2 Answers 2

0

In case it helps others, here are the steps I took to use MrSID and ECW through GDAL:

(1a) Download the 32 bit Visual Studio 2022 DSDK from https://www.extensis.com/support/developers. Unzip it to C:\Users\michael.katz\Documents\vcpkg\sdk\MrSID_DSDK-9.5.5.5244-win32-vc17.

(1b) Go to https://supportsi.hexagon.com/help/s/article/ERDAS-ECW-JP2-SDK-Read-Only-Redistributable-download and download the appropriate SDK in the top-right corner. Unzip the download to C:\Users\michael.katz\Documents\vcpkg\sdk\ecw\Hexagon\ERDAS_ECW_JPEG_2000_SDK_5.5.0\Desktop_Read-Only.

(2) Edit C:\Users\michael.katz\Documents\vcpkg\triplets\x86-windows.cmake. (You can see the meaning of the flags at https://gdal.org/development/building_from_source.html.)

set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(ENV{CMAKE_WINDOWS_KITS_10_DIR} "C:\\Program Files (x86)\\Windows Kits\\10")
set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_WINDOWS_KITS_10_DIR=C:/Program Files (x86)/Windows Kits/10\"")
set(VCPKG_ENV_PASSTHROUGH CMAKE_WINDOWS_KITS_10_DIR)

# CMAKE_CURRENT_LIST_DIR is the triplets directory
# such as C:/Users/michael.katz/Documents/vcpkg/triplets
message( STATUS "\n\n-----------------------CMAKE_CURRENT_LIST_DIR = ${CMAKE_CURRENT_LIST_DIR}\n\n" )

if (PORT MATCHES "gdal")
    string(
        CONCAT x
        " \"-DMRSID_INCLUDE_DIR=${CMAKE_CURRENT_LIST_DIR}/../sdk/MrSID_DSDK-9.5.5.5244-win32-vc17/Raster_DSDK/include\""
        " \"-DMRSID_LIBRARY=${CMAKE_CURRENT_LIST_DIR}/../sdk/MrSID_DSDK-9.5.5.5244-win32-vc17/Raster_DSDK/lib/lti_dsdk.lib\""
        " \"-DGDAL_USE_MRSID=ON\""
        " \"-DECW_INCLUDE_DIR=${CMAKE_CURRENT_LIST_DIR}/../sdk/ecw/Hexagon/ERDAS_ECW_JPEG_2000_SDK_5.5.0/Desktop_Read-Only/include\""
        " \"-DECW_LIBRARY=${CMAKE_CURRENT_LIST_DIR}/../sdk/ecw/Hexagon/ERDAS_ECW_JPEG_2000_SDK_5.5.0/Desktop_Read-Only/lib/vc141/Win32/NCSEcw.lib\""
        " \"-DGDAL_USE_ECW=ON"
    )
    set(VCPKG_CMAKE_CONFIGURE_OPTIONS "${VCPKG_CMAKE_CONFIGURE_OPTIONS} ${x}" )
endif()

message( STATUS "\n\n-----------------------VCPKG_CMAKE_CONFIGURE_OPTIONS = ${VCPKG_CMAKE_CONFIGURE_OPTIONS}\n\n" )

message( STATUS "\n\n-----------------------FEATURES = ${FEATURES}\n\n" )

# message( STATUS "\n\n-----------------------VCPKG_CXX_FLAGS = ${VCPKG_CXX_FLAGS}\n\n" )

(3) Build gdal, but first remove the old gdal:

PS C:\Users\michael.katz\Documents\vcpkg> rmdir C:\Users\michael.katz.la\AppData\Local\vcpkg\archives

PS C:\Users\michael.katz\Documents\vcpkg> .\vcpkg.exe remove gdal

PS C:\Users\michael.katz\Documents\vcpkg> rm C:\Users\michael.katz\Documents\vcpkg\buildtrees\gdal\x86-windows-rel\CMakeCache.txt

PS C:\Users\michael.katz\Documents\vcpkg> .\vcpkg.exe install gdal

(4a) Add ...MrSID_DSDK-9.5.5.5244-win32-vc17\Raster_DSDK\lib\lti_dsdk.lib as a linker input for your project.

(4b) Add ...Desktop_Read-Only\lib\vc141\Win32\NCSEcw.lib as a linker input for your project.

(5a) Copy ...MrSID_DSDK-9.5.5.5244-win32-vc17\Raster_DSDK\lib\lti_dsdk_9.5.dll to the Release directory of your project, so it's a sibling to your app.exe.

(5b) Copy ...Desktop_Read-Only\redistributable\vc141\Win32\NCSEcw.dll to the Release directory of your project, so it's a sibling to your app.exe.

(6) Rebuild your project.

-1

I had the exact same problem within a few days of you (but posted on stackoverflow instead of here), your fix with modifying the triplet didn't work for me, but I was able to modify the port and get it working.

Here's my answer in case anyone else runs into this: https://stackoverflow.com/a/76766286/8177594

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.