IMO you ask for trouble when you manually inject -DFRMT_mrsid=ON  into CFLAGS and CXXFLAGS. This is CMake input ("ON"!). Let the configuration do that for you. Did configuration successfully detect the dependency? Check the config logs.

Kai

Am 22.02.25 um 05:15 schrieb Michael Katz via gdal-dev:
I am getting the following link errors when building my application in MSVC++:

1>gdal.lib(gdalallregister.cpp.obj) : error LNK2019: unresolved external symbol _GDALRegister_ECW referenced in function _GDALAllRegister@0 1>gdal.lib(gdalallregister.cpp.obj) : error LNK2019: unresolved external symbol _GDALRegister_JP2ECW referenced in function _GDALAllRegister@0 1>gdal.lib(gdalallregister.cpp.obj) : error LNK2019: unresolved external symbol _GDALRegister_MrSID referenced in function _GDALAllRegister@0

I am linking statically to GDAL built as a static library with vcpkg (which builds without error). I am using a custom x86-windows.cmake file with vcpkg, customized mainly to include MrSID and ECW functionality in GDAL. I have pasted the cmake text at the bottom of this email.

From what I can see in the GDAL code, it's behaving as if
gdal/frmts/mrsid/mrsiddataset.cpp (which contains the function GDALRegister_MrSID) wasn't compiled into the library, yet the following code in frmts/gdalallregister.cpp was compiled.

#ifdef FRMT_mrsid
    GDALRegister_MrSID();
#endif

Can you help me understand how this could happen? What actually controls whether gdal/frmts/mrsid/mrsiddataset.cpp gets compiled into the library?


---
x86-windows.cmake:

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\""
" \"-DFRMT_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\""
" \"-DFRMT_ecw=ON\""
    )
    set(VCPKG_CMAKE_CONFIGURE_OPTIONS "${VCPKG_CMAKE_CONFIGURE_OPTIONS} ${x}" )
    set(VCPKG_CXX_FLAGS "${VCPKG_CXX_FLAGS} -DFRMT_mrsid=ON")
    set(VCPKG_C_FLAGS "${VCPKG_C_FLAGS} -DFRMT_mrsid=ON")
    set(VCPKG_CXX_FLAGS "${VCPKG_CXX_FLAGS} -DFRMT_ecw=ON")
    set(VCPKG_C_FLAGS "${VCPKG_C_FLAGS} -DFRMT_ecw=ON")
endif()

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

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



_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to