Michael,

I noticed you said the following:

"I am linking statically to GDAL built as a static library with vcpkg
(which builds without error)."

I may be interpreting this incorrectly, but it sounds like you intend to
link the NCSEcw library. However, I believe your ECW_LIBRARY variable
references the dynamic NCSEcw.lib import library. If you are trying to link
this library statically, I believe you need to use the following library:

ERDAS_ECW_JPEG_2000_SDK_5.5.0.zip\Desktop_Read-Only\lib\vc141\Win32\NCSEcwS.lib

or for an x64 build:

ERDAS_ECW_JPEG_2000_SDK_5.5.0.zip\Desktop_Read-Only\lib\vc141\x64\NCSEcwS.lib

I apologize if I've misinterpreted you here or if I'm giving you incorrect
information (I am somewhat new to this as well).

As far as linking this library statically, I have not successfully done
this when building using vcpkg. I have been able to build with dynamic
linking which is okay for our purposes (though not ideal). If you get
static linking working, I'd love to hear how you did it. Thank you,


On Sat, Feb 22, 2025 at 2:15 AM Kai Pastor, DG0YT via gdal-dev <
gdal-dev@lists.osgeo.org> wrote:

> 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 
> listgdal-dev@lists.osgeo.orghttps://lists.osgeo.org/mailman/listinfo/gdal-dev 
> <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
>


-- 
David Klaus
Carlson Software

Disclaimer

The information contained in this communication from the sender is 
confidential. It is intended solely for use by the recipient and others 
authorized to receive it. If you are not the recipient, you are hereby notified 
that any disclosure, copying, distribution or taking action in relation of the 
contents of this information is strictly prohibited and may be unlawful.
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to