Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link dynamic C runtime with clang (windows)

Tags:

c++

c

windows

clang

Clang on windows (using msvc libs) links with libcmt (the static runtime library) by default. Is there an easy way to link with the dynamic library (msvcrt)?

Normally, clang adds -defaultlib:libcmt to the linker command, which links the program to the static runtime. This occurrs even if the source file is blank.

The way I've found you can is by adding the options -Wl,-nodefaultlib:libcmt -D_DLL -lmsvcrt to override the default. However, this seems quite awkward. Is there a better way of linking the dynamic runtime than this?

like image 331
ralismark Avatar asked Jan 25 '17 11:01

ralismark


1 Answers

I had a similar problem and found I had to link against msvcrt, vcruntime and ucrt. See this post for more information https://devblogs.microsoft.com/cppblog/introducing-the-universal-crt/.

like image 72
user975326 Avatar answered Sep 21 '22 05:09

user975326