← All tasks
cpplief-project/LIEF #948Not a task: already works

Let CMake automagically pick `_ITERATOR_DEBUG_LEVEL` for Windows

envgap__lief-project__LIEF-948

01 / FAILURE SIGNATURE

As reported upstream

Statically compile LIEF (Debug) against a Debug shared library without deleting the lines mentioned (will throw `_ITERATOR_DEBUG_LEVEL mismatch` error)
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
bab28ae0628fc6b6fa29fcafcfb7277f48ce0f40
Manifest
CMakeLists.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

lief-project/LIEF #948 · read the original issue
**Describe the bug**

Windows doesn't seem to let you link two objects when there is a mismatch between the value of `_ITERATOR_DEBUG_LEVEL` between them. The default value for `_ITERATOR_DEBUG_VALUE` on a Debug build is `2`, but LIEF is manually overwriting that value with `0`, which makes the linker not allow the linkage between LIEF and a standard Debug binary.

Removing the following lines made everything work again: https://github.com/lief-project/LIEF/blob/master/CMakeLists.txt#L165-L168



**To Reproduce**

Statically compile LIEF (Debug) against a Debug shared library without deleting the lines mentioned (will throw `_ITERATOR_DEBUG_LEVEL mismatch` error)



**Expected behavior**

LIEF should allow CMake to pick the value for this compiler variable instead of overriding it. That would allow Debug binaries to compile and link normally.



**Environment (please complete the following information):**

 - System and Version : Windows 7 x64 - Visual Studio 2022 (Compiling for x86)

 - Target format (PE, ELF, Mach-O): PE (not relevant)

 - LIEF commit version: bab28ae0628fc6b6fa29fcafcfb7277f48ce0f40



**Additional context**

FIX: Deleting the following lines (165-168) from `CMakeLists.txt`:

```c

if(CMAKE_BUILD_TYPE MATCHES Debug AND WIN32)

  add_definitions(-D_ITERATOR_DEBUG_LEVEL=0 -D_SECURE_SCL=0

                  -D_HAS_ITERATOR_DEBUGGING=0)

endif()

```

Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]