abseil / abseil/abseil-cpp

[Bug]: Compilation issue on Windows 2022 with Ninja and CMake

Open
#1,701 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
18.1k
Forks
3.2k
Avg merge
20h 36m
Merged PRs (30d)
1

Description

### Describe the issue

I am using the latest LTS 20240116.2. I am on Windows with visual studio 2022 and I use Ninja and CMake to build Abseil in shared library.
I cannot build from scratch Abseil, I have the following message, which does not clearly say something about the error:
```
[155/170] Linking CXX shared library bin\abseil_dll.dll
FAILED: bin/abseil_dll.dll absl/abseil_dll.lib
cmd.exe /C "cmd.exe /C ""C:\Program Files\CMake\bin\cmake.exe" -E __create_def C:\Users\arnau\Documents\Code\OpenGeode\build\third_party\abseil\build\absl\CMakeFiles\abseil_dll.dir\.\exports.def C:\Users\arnau\Documents\Code\OpenGeode\build\third_party\abseil\build\absl\CMakeFiles\abseil_dll.dir\.\exports.def.objs && cd C:\Users\arnau\Documents\Code\OpenGeode\build\third_party\abseil\build" && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_dll --intdir=absl\CMakeFiles\abseil_dll.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1440~1.338\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\abseil_dll.rsp /out:bin\abseil_dll.dll /implib:absl\abseil_dll.lib /pdb:bin\abseil_dll.pdb /dll /version:0.0 /machine:x64 /debug /INCREMENTAL /INCREMENTAL:NO /LTCG /DEF:absl\CMakeFiles\abseil_dll.dir\.\exports.def && cd ."
```

Thanks for the help.

### Steps to reproduce the problem

I am using ExternalProject_Add from CMake to configure and build Abseil. So it runs cmake with the following options and than build it.

```
ExternalProject_Add(abseil
PREFIX ${ABSEIL_PATH}
SOURCE_DIR ${ABSEIL_PATH}/src
BINARY_DIR ${ABSEIL_PATH}/build
STAMP_DIR ${ABSEIL_PATH}/stamp
GIT_REPOSITORY https://github.com/abseil/abseil-cpp
GIT_TAG 20240116.2
GIT_SHALLOW ON
GIT_PROGRESS ON
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_ARGS
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_MESSAGE=LAZY
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
-DCMAKE_POLICY_DEFAULT_CMP0091=NEW
-DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=${CMAKE_MSVC_RUNTIME_LIBRARY}
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=${CMAKE_INTERPROCEDURAL_OPTIMIZATION}
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=${ABSEIL_INSTALL_PREFIX}
)
```

### What version of Abseil are you using?

LTS 20240116.2

### What operating system and version are you using?

Windows

### What compiler and version are you using?

visual studio 2022, C++17

### What build system are you using?

cmake version 3.27.1 and ninja 1.11.1

### Additional context

I run the compilation another time, than it works. Here the log of the second try.
```
[1/16] Linking CXX shared library bin\abseil_dll.dll
[2/16] Linking CXX static library absl\flags\absl_flags_commandlineflag_internal.lib
[3/16] Linking CXX static library absl\flags\absl_flags_program_name.lib
[4/16] Linking CXX static library absl\flags\absl_flags_marshalling.lib
[5/16] Linking CXX static library absl\log\absl_log_internal_fnmatch.lib
[6/16] Linking CXX static library absl\strings\absl_string_view.lib
[7/16] Linking CXX static library absl\flags\absl_flags_commandlineflag.lib
[8/16] Linking CXX static library absl\flags\absl_flags_config.lib
[9/16] Linking CXX static library absl\log\absl_vlog_config_internal.lib
[10/16] Linking CXX static library absl\flags\absl_flags_private_handle_accessor.lib
[11/16] Linking CXX static library absl\flags\absl_flags_internal.lib
[12/16] Linking CXX static library absl\flags\absl_flags_reflection.lib
[13/16] Linking CXX static library absl\log\absl_log_flags.lib
[14/16] Linking CXX static library absl\flags\absl_flags_usage_internal.lib
[15/16] Linking CXX static library absl\flags\absl_flags_usage.lib
[16/16] Linking CXX static library absl\flags\absl_flags_parse.lib
[61/74] Performing install step for 'abseil'
```

I also tried with visual studio instead of Ninja, the result is the same.
Do you have an idea of the issue? It is hard to run twice the compilation on our CI, I would prefer find the origin of the problem.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.