Skip to content

lld-link is looking for libs with "md" or "mt" suffix even if not asked to #164982

@cosminpolifronie

Description

@cosminpolifronie

Hello! I am having issues with the lld-link on Windows. It is trying to link against non-existing libraries, even though it was not asked to look for them.

Ninja version: 1.13.1
CMake version: 4.1.1
Example:
main.cpp:

#include <Poco/UUIDGenerator.h>
#include <iostream>

int main()
{
    Poco::UUIDGenerator uuidGen;
    Poco::UUID uuid = uuidGen.createRandom();
    std::cout << "Generated UUID: " << uuid.toString() << std::endl;
    return 0;
}

CMakeLists.txt:

cmake_minimum_required(VERSION 3.18)
project(testproj LANGUAGES CXX)

set(CMAKE_DEBUG_POSTFIX "d")
add_executable(testproj main.cpp)
target_include_directories(testproj PUBLIC C:/poco/include)
target_link_libraries(testproj PUBLIC C:/poco/lib/PocoFoundationd.lib)
target_compile_definitions(testproj PRIVATE POCO_STATIC)

Configure and build command:

cmake . -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug
cmake --build .

Build succeeds but link fails with the following error:

[2/2] Linking CXX executable testproj.exe
FAILED: [code=1] testproj.exe
C:\WINDOWS\system32\cmd.exe /C "cd . && C:\tools\clang+llvm-21.1.3-x86_64-pc-windows-msvc\bin\clang++.exe -nostartfiles -nostdlib -O0 -g -Xclang -gcodeview -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -Xlinker /subsystem:console -fuse-ld=lld-link CMakeFiles/testproj.dir/main.cpp.obj -o testproj.exe -Xlinker /MANIFEST:EMBED -Xlinker /implib:testproj.lib -Xlinker /pdb:testproj.pdb -Xlinker /version:0.0   C:/poco/lib/PocoFoundationd.lib  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames  && cd ."
lld-link: error: could not open 'PocoFoundationmdd.lib': no such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Issue is present in both 20.1.8 and 21.1.3.

PocoFoundationd.lib is part of a custom Poco build with some patches added. The lib is dynamically linked against the MSVC runtime with /MDd flags.

Why is lld-link looking for PocoFoundationmdd.lib when it is asked to link against PocoFoundationd.lib?

If I try to use an /MTd version of Poco, it will look for PocoFoundationmtd.lib with the same "no such file or directory" error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lld:COFFquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions