Skip to content

[WIN/CLANG/CMAKE] Incorrect linker flags when configuring on the Windows. #1863

@alexv-ds

Description

@alexv-ds

Godot version

no matter

godot-cpp version

godot-4.5-stable

System information

Windows 11

Issue description

Incorrect linker flags are used when building the project in the Windows + Clang (GNU-like CLI) + Ninja + CMake environment

FAILED: [code=1] reproduce.dll reproduce.lib 
C:\Windows\system32\cmd.exe /C "cd . && C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -nostartfiles -nostdlib -O0 -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -g -Xclang -gcodeview  -shared -Wl,--no-undefined -lstdc++ -fuse-ld=lld-link -o reproduce.dll  -Xlinker /MANIFEST:EMBED -Xlinker /implib:reproduce.lib -Xlinker /pdb:reproduce.pdb -Xlinker /version:0.0 CMakeFiles/reproduce.dir/empty.cpp.obj  bin/libgodot-cpp.windows.template_debug.x86_64.lib  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames  && cd ."
lld-link: warning: ignoring unknown argument '--no-undefined'
lld-link: error: could not open 'stdc++.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.

Incorrect linker flags are added here. I assume this was written with the expectation that we are using MinGW/MSYS with a POSIX runtime, but that’s not the case here.

t would be nice to have an option to prevent targets that use godot-cpp from being polluted with its PUBLIC linker flags, and instead allow the higher-level project (the one that calls add_subdirectory(godot-cpp)) to control them.

Steps to reproduce

  1. Download reproduce.zip
  2. Configure (options below)
  3. Try to build
  4. Wait for the linking stage

Configure options:
-G Ninja
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_MAKE_PROGRAM=ninja
-DCMAKE_C_COMPILER=C:/Program Files/LLVM/bin/clang.exe (It’s possible to use Clang installed via Chocolatey)
-DCMAKE_CXX_COMPILER=C:/Program Files/LLVM/bin/clang++.exe

Minimal reproduction project

reproduce.zip

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions