Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake(MSVC): building ortools_full.lib is not working in Debug #3822

Open
2 tasks
Mizux opened this issue Jun 13, 2023 · 4 comments
Open
2 tasks

cmake(MSVC): building ortools_full.lib is not working in Debug #3822

Mizux opened this issue Jun 13, 2023 · 4 comments
Assignees
Labels
Bug Build: CMake CMake based build issue Lang: C++ Native implementation issue OS: Windows Windows OS
Projects
Milestone

Comments

@Mizux
Copy link
Collaborator

Mizux commented Jun 13, 2023

As spotted by user the cmake/bundle-install.cmake.in is not working in config Debug since we don't take into account the variable CMAKE_DEBUG_POSTFIX.

here we should add few wildcard (or better use ${CMAKE_DEBUG_POSTFIX}) to find the correct static lib dependencies

set(DEPS absl_*.lib zlib.lib re2.lib *protobuf.lib)
if (@BUILD_Cbc@)
set(DEPS ${DEPS} Cbc*.lib)
endif()
if (@BUILD_Cgl@)
set(DEPS ${DEPS} Cgl.lib)
endif()
if (@BUILD_Clp@)
set(DEPS ${DEPS} Clp*.lib)
endif()
if (@BUILD_Osi@)
set(DEPS ${DEPS} Osi*.lib)
endif()
if (@BUILD_CoinUtils@)
set(DEPS ${DEPS} CoinUtils.lib)
endif()
if (@BUILD_SCIP@)
set(DEPS ${DEPS} libscip.lib)
endif()
if (@BUILD_GLPK@)
set(DEPS ${DEPS} libglpk.lib)
endif()

Todo:

  • Fix debug postfix managment
  • Add ci job to test it

ref: https://cmake.org/cmake/help/latest/variable/CMAKE_CONFIG_POSTFIX.html#variable:CMAKE_%3CCONFIG%3E_POSTFIX

@Mizux Mizux added Bug OS: Windows Windows OS Build: CMake CMake based build issue Lang: C++ Native implementation issue labels Jun 13, 2023
@Mizux Mizux added this to the v9.7 milestone Jun 13, 2023
@Mizux Mizux self-assigned this Jun 13, 2023
@Mizux Mizux added this to To do in ToDo via automation Jun 13, 2023
@Mizux Mizux modified the milestones: v9.7, v9.8 Jul 28, 2023
@Mizux Mizux moved this from To do to Stall in ToDo Jul 28, 2023
@Mizux Mizux modified the milestones: v9.8, v9.9 Oct 19, 2023
@Mizux
Copy link
Collaborator Author

Mizux commented Mar 4, 2024

to test:

cmake -S. -Bbuild -DBUILD_DEPS=ON
cmake --build build --config Debug -v -j 8
cmake --install build --config Debug --prefix install

ref:

@Mizux
Copy link
Collaborator Author

Mizux commented Mar 4, 2024

Postponed to next release since even Debug build seems broken:
trace:

 cmake --build build --config Debug -v -j 12
 ...
"C:\Users\...\or-tools\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\...\or-tools\build\ortools\math_opt\samples\cpp\cutting_stock.vcxproj" (default target) (173) ->
absl_synchronization.lib(mutex.obj) : error LNK2005: "private: void __cdecl absl::lts_20240116::Mutex::Dtor(void)" (?Dtor@Mutex@lts_20240116@absl@@AEAAXXZ) already defined in ortools.lib(model_storage.obj)
[C:\Users\...\or-tools\build\ortools\math_opt\samples\cpp\cutting_stock.vcxproj]
C:\Users\...\or-tools\build\DEBUG\bin\cutting_stock.exe : fatal error LNK1169: one or more multiply defined symbols found 
[C:\Users\...\or-tools\build\ortools\math_opt\samples\cpp\cutting_stock.vcxproj]

same for any executable -> need to dig for next release...

@Mizux Mizux modified the milestones: v9.9, v10.0 Mar 4, 2024
@EddyXorb
Copy link

EddyXorb commented Apr 3, 2024

Postponed to next release since even Debug build seems broken: trace:

 cmake --build build --config Debug -v -j 12
 ...
"C:\Users\...\or-tools\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\...\or-tools\build\ortools\math_opt\samples\cpp\cutting_stock.vcxproj" (default target) (173) ->
absl_synchronization.lib(mutex.obj) : error LNK2005: "private: void __cdecl absl::lts_20240116::Mutex::Dtor(void)" (?Dtor@Mutex@lts_20240116@absl@@AEAAXXZ) already defined in ortools.lib(model_storage.obj)
[C:\Users\...\or-tools\build\ortools\math_opt\samples\cpp\cutting_stock.vcxproj]
C:\Users\...\or-tools\build\DEBUG\bin\cutting_stock.exe : fatal error LNK1169: one or more multiply defined symbols found 
[C:\Users\...\or-tools\build\ortools\math_opt\samples\cpp\cutting_stock.vcxproj]

same for any executable -> need to dig for next release...

I confirm that. It happens exactly to me using vs 2022 and only on debug build.

I think it has to do with a recent change in abseils Mutex::Dtor.
There is a condition that inlines the Mutex::Dtor when NDEBUG is defined for performance reasons, and defines it in mutex.cc otherwise with a debug logging machinery in this Dtor, which was formerly (202308) the default in every case: abseil/abseil-cpp@f3760b4

A simple solution would be to patch this part back to the abseil 202308-state, or wait for the already open issue to be resolved for the next release of abseil, see:

This error however makes me think that the reason may as well be in how ortools' cmake is configured. Maybe DEBUG is not always set for every target or the BUILD_ABSEIL_DLL is not correctly set, I did not check it so far.

Regarding the original issue of bundle install not working on windows: I confirm that it does not work be it on Debug or Release. The execute command fails in both configs, saying it does not find libortools_all.lib (during removal call at top of bundle-install.cmake).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Build: CMake CMake based build issue Lang: C++ Native implementation issue OS: Windows Windows OS
2 participants