Open SunBlack opened 1 day ago
A workaround is that you use CMake Release or RelWithDebInfo builds, not Debug one
A workaround is that you use CMake Release or RelWithDebInfo builds, not Debug one
Tried it, but doesn't work. When we are building our framework in Debug mode, but using Release GDAL libraries, we are getting SEH expception. When building Release and RelWithDebInfo (with -DCMAKE_RELWITHDEBINFO_POSTFIX=d
, so that the two build types do not overwrite each other), CMake sadly prefers the Release library instead the RelWithDebInfo.
Tried it, but doesn't work. When we are building our framework in Debug mode, but using Release GDAL libraries, we are getting SEH expception.
ah yes, that's a Windows thing where the ABI of the C++ standard library changes between debug and release. Nothing that GDAL can do about.
Tried it, but doesn't work. When we are building our framework in Debug mode, but using Release GDAL libraries, we are getting SEH expception.
ah yes, that's a Windows thing where the ABI of the C++ standard library changes between debug and release. Nothing that GDAL can do about.
Yep. Actually, my idea now is to backport the fix from #11314. So if the version is <= 3.10.0, that it adds the flag to the imported target. However, this would possibly break the vcpkg setup, because for some reason it runs without the flag. That's why I'm currently still looking for what the vcpkg port does differently.
Btw: We need for Linux also a separate Debug build as we compile our framework with _GLIBCXX_DEBUG
and therefore also all dependencies needs to be compiled with it (for better assertions). Somehow the missing DEBUG
is okay for the linker.
Ok I think I found the reason, why vcpkg works for us. As we are still using GDAL 3.8.5 there, so this commit is still not relevant for us: bfed07022e49b916c842afb591b636397d8f55e0. As vcpkg builds the dependencies the MSVC
tree will not be entered (I think). Therefore the Debug-Flag will not be set.
So without testing: Could be it, that OGRSpatialReference::FindMatches
is also not working for the vcpkg build 3.9.0 and newer?
What is the bug?
Currently we have issues switching from an old GDAL version (3.3.3 - nmake build systems) to a new one (3.5+ - cmake build system) as the linker fails in debug mode. Specifically, we have the linker problem with
OGRSpatialReference::FindMatches
.With vcpk, on the other hand, we don't have the linker issue. That's why I used
dumpbin
to inspect thegdald.lib
:dumpbin
with GDAL compiled via vcpkg:?FindMatches@OGRSpatialReference@@QEBAPEAPEAUOGRSpatialReferenceHS@@PEAPEADPEAHPEAPEAH@Z
(public: struct OGRSpatialReferenceHS * __ptr64 * __ptr64 __cdecl OGRSpatialReference::FindMatches(char * __ptr64 * __ptr64,int * __ptr64,int * __ptr64 * __ptr64)const __ptr64
)dumpbin
with self compiled GDAL:?FindMatches@OGRSpatialReference@@QEBAPEAPEAXPEAPEADPEAHPEAPEAH@Z
(public: void * __ptr64 * __ptr64 __cdecl OGRSpatialReference::FindMatches(char * __ptr64 * __ptr64,int * __ptr64,int * __ptr64 * __ptr64)const __ptr64
)As you can see, the return type differs. The reason for this is this:
For some reason
DEBUG
is defined during building self compiled GDAL, but during compiling via vcpkg. Unfortunately, I have not yet found where this macro is defined, as it is not actually a predefined one (_DEBUG
is predefined, but notDEBUG
, see here). If you create a simple CMake project that has only one executable, set the debug mode in MSVC, and copy in the above#ifdef
from GDAL, you will also see thatDEBUG
is not defined this case.So the question is: Where is
DEBUG
defined? And shouldn't it be exported so that it is active for the GDAL headers when it is included?Steps to reproduce the issue
1) Build GDAL with default settings 2) Create a simple CMake project with just a executable
Versions and provenance
Windows 10/11
Additional context
No response