[abseil] LNK2005 linker errors with C++/CLI project
@Mengna-Li is already working on this.
Since Feb 26, 2025.
- Dominant language
- CMake
- Stars
- 27.5k
- Forks
- 7.7k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 321
Description
### Operating system
Windows
### Compiler
MSVC
### Steps to reproduce the behavior
```Shell
1. Create a simple C++/CLI console program using the VS template
2. Add vcpkg support
3. Add abseil dependency
4. Build and observe LNK2005 linker errors
```
### Failure logs
Build started at 14:01...
1>------ Build started: Project: TestVcpkg, Configuration: Debug x64 ------
1>TestVcpkg.cpp
1>.NETFramework,Version=v4.7.2.AssemblyAttributes.cpp
1>Generating Code...
1>TestVcpkg.obj : MSIL module encountered; incremental linking is disabled for MSIL; performing full link
1>MSVCRTD.lib(throw_bad_alloc.obj) : error LNK2005: "public: __cdecl std::bad_alloc::bad_alloc(class std::bad_alloc const &)" (??0bad_alloc@std@@QEAA@AEBV01@@Z) already defined in abseil_dll.lib(abseil_dll.dll)
1>MSVCRTD.lib(throw_bad_alloc.obj) : error LNK2005: "public: __cdecl std::bad_array_new_length::bad_array_new_length(class std::bad_array_new_length const &)" (??0bad_array_new_length@std@@QEAA@AEBV01@@Z) already defined in abseil_dll.lib(abseil_dll.dll)
1>MSVCRTD.lib(throw_bad_alloc.obj) : error LNK2005: "public: __cdecl std::exception::exception(class std::exception const &)" (??0exception@std@@QEAA@AEBV01@@Z) already defined in abseil_dll.lib(abseil_dll.dll)
1>MSVCRTD.lib(throw_bad_alloc.obj) : error LNK2005: "public: virtual __cdecl std::bad_array_new_length::~bad_array_new_length(void)" (??1bad_array_new_length@std@@UEAA@XZ) already defined in abseil_dll.lib(abseil_dll.dll)
1>MSVCRTD.lib(throw_bad_alloc.obj) : error LNK2005: "public: virtual char const * __cdecl std::exception::what(void)const " (?what@exception@std@@UEBAPEBDXZ) already defined in abseil_dll.lib(abseil_dll.dll)
1>C:\Code\TestVcpkg\x64\Debug\TestVcpkg.exe : fatal error LNK1169: one or more multiply defined symbols found
1>Done building project "TestVcpkg.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 14:01 and took 02.922 seconds ==========
### Additional context
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.