1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

MinGW 環境で UCRT(Universal CRT) ライブラリを使って C アプリをビルドするメモ

Last updated at Posted at 2020-06-21

背景

  • MSVC 非依存で Windows C/C++ アプリを mingw, clang でビルドしたい
  • せっかくなので, UCRT を使ってみたい
    • UCRT でなくとも, 一応は MSVC 非依存でビルドできる

UCRT(Universal CRT)

最近の推奨? C/C++ アプリ開発者から見ると, いわゆる C runtime(glibc)相当.
UWP(Universal Windows Platform)用にビルドするには UCRT が必要(+ UNICODE 環境オンリー)

MinGW 環境でビルドする

Windows SDK にある UCRT のヘッダは, vcruntime.h などに依存しており, mingw(gcc, clang)ではビルドできない(MSVC header が別途必要)

MinGW に作成したヘッダを使う. _UCRT を定義する.

llvm-mingw では libvcruntime140_app.a がすでにあるのでこちらを利用すればよい

注意事項

  • UCRT には C++ STL は含まれていない
    • llvm-mingw を見る限り, libc++ とはうまく組み合わせることができるっぽい
  • d3d12.h などは, 一応頑張ればいけるっぽい.
    • d3d12 API 自体が実際には C++ なコードなので, C++ モードにしてコンパイルが必要
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?