Search code examples
c++visual-c++clangclang-cl

Is it possible to generate a .lib file on windows using clang-cl?


I am on Windows and I have Visual Studio installed and the latest version of clang. I am able to run:

clang-cl hello.c

Which in turn generates hello.exe, which I can run as expected.

But what I want to do is to generate a static library instead (.lib file). I am able to pass the /LD flag to generate a dynamic link library but I can't figure out how to generate a static library instead.

Is this possible to do with clang-cl?


Solution

  • Yes, it seems to be possible.

    Use -fuse-ld=llvm-lib to link multiple source files into a static library