メモです

バイナリとかを調べてみます

WinのコマンドプロンプトでC(++)コンパイラを動かしたい、x86とx86-64ともに

Build Tools for Visual Studio 2022(ビルドツール for Visual Studio 2022)のインストール(Windows 上)
こちらを参考にさせていただきました。

1.Build Tools for Visual Studio 202をダウンロード

https://visualstudio.microsoft.com/ja/downloads/
こちらに行き、
「Build Tools for Visual Studio 2022」をダウンロードする。
"vs_BuildTools.exe"このファイルが取得できる。

2.Build Tools for Visual Studio 202 をインストール

"vs_BuildTools.exe"を実行してインストール。
インストールする項目は、「C++ によるデスクトップ開発」を選択する。

3.x86-64x86の実行ファイルを作成
  • x86-64実行ファイルを作成する。

「x64 Native Tools Command Prompt for VS 2022」を開く。

> where cl
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64\cl.exe

> cd %HOMEPATH%
> notepad.exe hello64.c
/* hello64.c */
#include <stdio.h>

int main() {
	printf("Hello, world!\n");
	printf("sizeof(size_t)=%ld\n", sizeof(size_t));
	return 0;
}
> cl hello64.c
> hello64.exe
Hello, world!
sizeof(size_t)=8
  • x86実行ファイルを作成する。

x86 Native Tools Command Prompt for VS 2022」を開く。

> where cl
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\bin\Hostx86\x86\cl.exe

> cd %HOMEPATH%
> notepad.exe hello86.c
/* hello86.c */
#include <stdio.h>

int main() {
	printf("Hello, world!\n");
	printf("sizeof(size_t)=%ld\n", sizeof(size_t));
	return 0;
}
> cl hello86.c
> hello86.exe
Hello, world!
sizeof(size_t)=4