Visual Studio(MSBuild)ã§VC++ããã«ãããã¨ãã®ç®æ¡æ¸ãã¡ã¢. MyProjectã¨ããã¦ã¤ã³ãã¦ãæã¤MFCããã¸ã§ã¯ãã®x64ãã«ããæ³å®.
å®è¡ç°å¢
é ç® | 説æ |
---|---|
OS | Windows11 |
Visual Studio | 2017 |
ãã«ãã¿ã¼ã²ãã | x64 |
é¢é£ãããã¹
ãã¹ | 主ãªãã¡ã¤ã« | 説æ |
---|---|---|
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64 | cl.exe, link.exe, nmake.exe, dumpbin.exe | ãã¤ããªãã¼ã« |
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include | iostream, algorithm | VC++ç¨ãããã¼ |
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64 | msvcrt.lib, legacy_stdio_definitions.lib | VC++ç¨ã©ã¤ãã©ãª |
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\include | afx.h, about_.rc | MFCã®ãããã¼, ããã©ã«ãã®ãªã½ã¼ã¹ |
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\lib\x64 | mfc140.lib | MFCã®ã¤ã³ãã¼ããã¡ã¤ã« |
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools | MSBuild.exe, VsDevCmd.bat | MSBuildåã³ãã¹ãæå®ããããã®bat |
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE | devenv.exe | Visual Studio æ¬ä½ |
C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64 | rc.exe | Windowséçºç¨ã®ãã¼ã« |
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0 | winsock.h, WinBase.h | Cè¨èªã«ããWinã¢ããªã±ã¼ã·ã§ã³ç¨ãããã¼ãã¡ã¤ã« |
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64 | kernel32.LIB, d3d12.lib | Cè¨èªã«ããWinã¢ããªã±ã¼ã·ã§ã³ç¨ã¤ã³ãã¼ããã¡ã¤ã« |
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\ucrt\x64 | libucrt.lib, ucrt.lib | Cè¨èªã«ããWinã¢ããªã±ã¼ã·ã§ã³ç¨ã¤ã³ãã¼ããã¡ã¤ã« |
C:\Windows\System32 | kernel32.dll, msvcp140.dll, mfc140.dll, D3D12.dll, curl.exe | 64bitç¨ã©ã³ã¿ã¤ã , åºæ¬ã³ãã³ã |
ã©ã³ã¿ã¤ã ã¨SDK
ãã£ããè¨ãã¨ãã©ã³ã¿ã¤ã ã¯dllã§å®è¡æã«å¿ è¦. SDKã¯ãããã¼ãã¤ã³ãã¼ãã©ã¤ãã©ãªãããã¯ã¹ã¿ãã£ãã¯ã©ã¤ãã©ãªã§ãã«ãæã«å¿ è¦. ãããªãæãå¿ è¦ãªã©ã³ã¿ã¤ã ã¨ãããã¸ã§ã¯ãã®ç¨®é¡ã«ãã£ã¦ã¯å¿ è¦ãªã©ã³ã¿ã¤ã ããã. ã©ã³ã¿ã¤ã ã欲ããå ´åã¯åé å¸å¯è½ããã±ã¼ã¸ãåå¾ããã°ãã.
主è¦ãªã©ã³ã¿ã¤ã | 説æ |
---|---|
kernel32.dll | ããã¿ããã©ãªã«ãã¦ããã ãã |
ucrtbase.dll | ããã¿ããã©ãªã«ãã¦ããã ãã |
vcruntime140.dll | Visual Studio2015以éã®VC++ãã«ããã¼ã«ã§ä½ã£ãã¢ããªã®å®è¡ã«å¿ è¦ |
mfc140.dll | Visual Studio2015以éã®VC++ãã«ããã¼ã«ã§ä½ã£ãåçMFCã¢ããªã®å®è¡ã«å¿ è¦ |
ã©ã³ã¿ã¤ã ããã£ããåããã¨
- ã»ã¼ç¡æ¡ä»¶ã§å¿ è¦ãªãã®...kernel32.dllãªã©
- VC++ã§ä½ã£ãå ´åã«å¿ è¦ãªãã®...msvcr140.dllãªã©
- MFCã§ä½ã£ãå ´åã«å¿ è¦ãªãã®...mfc140.dllãªã©
ã¨ããã.
ãã¡ã¤ã«ã®é ç½®è¦å
- ãããã¼ãã¡ã¤ã«ã¯ã¿ã¼ã²ãããã¨ã«åããã«é ç½®
- ã¤ã³ãã¼ããã¡ã¤ã«ã¯ã¿ã¼ã²ãããã¨ã«ãã©ã«ããåãã¦é ç½®
- ã¤ã³ãã¼ããã¡ã¤ã«ã¨dllãã¡ã¤ã«ã¯ä¸å¯¾ä¸å¯¾å¿ã¨ã¯éããªã
- VC++ã®ãã«ããã¼ã«ã¯ãã¼ã¸ã§ã³ãã¨ã«åããã¦ãããããã«ããã¼ã«ã追å ã§ã¤ã³ã¹ãã¼ã«ããªãéãã¯1ã¤ãããªã
- WinSDKã®ãã¼ã«ãã©ã¤ãã©ãªã¯ãã¼ã¸ã§ã³ãã¨ã«åããã¦ãã. ä¸é¨ãã©ã«ãã¯WinSDKã¤ã³ã¹ãã¼ã«åããåå¨ãã
ãã¡ã¤ã«ã®å½åè¦å
- dãæ¡å¼µåã®åã«ã¤ãã¦ãããã¡ã¤ã«ã¯ãããã°ãã«ãç¨
- uãæ¡å¼µåã®åã«ã¤ãã¦ãããã¡ã¤ã«ã¯Unicode対å¿
- LIBãã.LIBã¨ãããã¡ã¤ã«ã¯ã¤ã³ãã¼ãã©ã¤ãã©ãªã§ã¯ãªãã¹ã¿ãã£ãã¯ã©ã¤ãã©ãª
- C:\Windows\System32ã¯64bitç¨ï¼ç´ãããã!ï¼. C:\Windows\SysWOW64ã¯32bitç¨ï¼ç´ãããã!ï¼.
- ã©ã³ã¿ã¤ã ã¯32bitã64bitãååã«ãã¦ãã. kernel32.dllã«ã64bitç¨ã®ãã®ã¨32bitç¨ã®ãã®ããã.
ãã«ãã®æµã
CL.exeã«ããã³ã³ãã¤ã« â rc.exeã«ãããªã½ã¼ã¹ã³ã³ãã¤ã« â link.exeã«ãããªã³ã¯
詳細
- ãã«ãã¿ã¼ã²ããã«å¯¾å¿ããã³ãã³ãããã³ãããéã
- msbuild.batãå¼ã³åºãããMSBuild.exeã¸ã®ãã¹ã追å ããã.
- winsdk.batãå¼ã³åºãããWindowsSDKVersionããèªåçã«æå®ããã(ããããPCã«å ¥ã£ã¦ãããã®ã®ä¸ã§ææ°ã®ãã®)
- vcvars.batã«ããVCãã«ããã¼ã«ã®ãã¼ã¸ã§ã³ãWinSDKã®ãã¼ã¸ã§ã³ãã¿ã¼ã²ããã«å¯¾å¿ããã¤ã³ã¯ã«ã¼ããã©ã«ããã©ã¤ãã©ãªãã©ã«ãã¸ã®ãã¹ãç°å¢å¤æ°ã«è¿½å .
- 1ã§éããã³ãã³ãããã³ãã㧠MSBuild <MyProjectã¸ã®ãã¹>\MyProject.vcxproj ã¨å©ã.
- MyProject.vcxprojå ã®VCãã«ããã¼ã«ã®ãã¼ã¸ã§ã³ã¨WinSDKã®ãã¼ã¸ã§ã³ã§ç°å¢å¤æ°ãä¸æ¸ãããããã§ãã«ãéå§.
IDEä¸ãããã«ãããã¨MSBuildã®ãªãã·ã§ã³ãæå®ããããã§ãã«ãã§ããï¼å¾è¿°)
ã¤ã³ãã¼ãã©ã¤ãã©ãª
vcvars.batã®ãããã§ãã¨ããããã¤ãã®ãã£ã¬ã¯ããªã¸ã®ãã¹ãéã£ã¦ãã. ä¾ãã°ãIDEä¸ã§ä»¥ä¸ã®ããã«æ¸ãã¦ããªã³ã¯ã¨ã©ã¼ã«ãªããªãã®ã¯ãC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\lib\x64ãããC:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64ããªã©ã¸ã®ãã¹ãvcvars.batã®ãããã§éã£ã¦ãããã.
/******************************************/ /* afx.hããã®æç² */ /*****************************************/ #ifndef _AFXDLL #ifdef _AFX_NO_MFC_CONTROLS_IN_DIALOGS #ifdef _DEBUG #pragma comment(lib, "afxnmcdd.lib") #else #pragma comment(lib, "afxnmcd.lib") #endif #pragma comment(linker, "/include:__afxNoMFCControlSupportInDialogs") #pragma comment(linker, "/include:__afxNoMFCControlContainerInDialogs") #endif #ifndef _UNICODE #ifdef _DEBUG #pragma comment(lib, "nafxcwd.lib") #else #pragma comment(lib, "nafxcw.lib") #endif #else #ifdef _DEBUG #pragma comment(lib, "uafxcwd.lib") #else #pragma comment(lib, "uafxcw.lib") #endif #endif #else #ifndef _UNICODE #ifdef _DEBUG #pragma comment(lib, "mfc" _MFC_FILENAME_VER "d.lib") #pragma comment(lib, "mfcs" _MFC_FILENAME_VER "d.lib") #else #pragma comment(lib, "mfc" _MFC_FILENAME_VER ".lib") #pragma comment(lib, "mfcs" _MFC_FILENAME_VER ".lib") #endif #else #ifdef _DEBUG #pragma comment(lib, "mfc" _MFC_FILENAME_VER "ud.lib") #pragma comment(lib, "mfcs" _MFC_FILENAME_VER "ud.lib") #else #pragma comment(lib, "mfc" _MFC_FILENAME_VER "u.lib") #pragma comment(lib, "mfcs" _MFC_FILENAME_VER "u.lib") #endif #endif #endif #ifdef _DLL #if defined(_DEBUG) #pragma comment(lib, "msvcrtd.lib") #else #pragma comment(lib, "msvcrt.lib") #endif #else #if defined(_DEBUG) #pragma comment(lib, "libcmtd.lib") #else #pragma comment(lib, "libcmt.lib") #endif #endif #pragma comment(lib, "kernel32.lib") #pragma comment(lib, "user32.lib") #pragma comment(lib, "gdi32.lib") #pragma comment(lib, "msimg32.lib") #pragma comment(lib, "comdlg32.lib") #pragma comment(lib, "winspool.lib") #pragma comment(lib, "advapi32.lib") #pragma comment(lib, "shell32.lib") #pragma comment(lib, "comctl32.lib") #pragma comment(lib, "shlwapi.lib") #pragma comment(lib, "uxtheme.lib") #pragma comment(lib, "windowscodecs.lib")
追å ã®ãã£ã¬ã¯ããª
vcvars.batã§è¿½å ããããã£ã¬ã¯ããªä»¥å¤ã¸ã®ãã¹ã追å ããå ´åã¯ãããã¸ã§ã¯ãããããã£ããã追å ã®ã¤ã³ã¯ã«ã¼ããã£ã¬ã¯ããªãã¨ã追å ã®ã©ã¤ãã©ãªãã£ã¬ã¯ããªãã®é ç®ã«ãã£ã¬ã¯ããªã¸ã®ãã¹ãæå®ãã. ã©ã¤ãã©ãªã«é¢ãã¦ã¯ããã¸ã§ã¯ãããããã£ã®ã追å ã®ä¾åãã¡ã¤ã«ãã«æå®ãã¦ããããã#pragma comment(lib, "libName") ãã½ã¼ã¹ãã¡ã¤ã«å ã«è¨è¿°ããã°ãã. ãããããããããã»ã¹ãã©ããã§ä¾åãã¡ã¤ã«ãèªåçã«ä½æãã¦ããã. vcvars.batã¯ããã¾ã§ãã¹ãæå®ããã ããªã®ã§ããããå 㧠#pragma comment(lib, "libName")ãè¨è¿°ãããã¨ã§ããã©ã«ãã®ä¾åé¢ä¿ãæå®ãã¦ãã.
ãã°
MyProject.tlogãã©ã«ãã«CLãrcãlinkã®ãã°ãåºåããã. ç¹ã«CLã¨linkã¯åç §ãããã¡ã¤ã«ããã¹ã¦ãã«ãã¹ã§åºåããã¦ããã®ã§å¿ è¦.
MSBuildã®ãªãã·ã§ã³
MSBuildãã³ãã³ãã©ã¤ã³ãããªãã·ã§ã³ãªãã§å®è¡ããã¨ãx64 Debug ãã«ãã«ãªã£ã¦ãã¾ã. /property (/p for short)ãªãã·ã§ã³ãæå®ããã¨ã³ãã³ãã©ã¤ã³ããã¿ã¼ã²ãããæå®ã§ãã.
MSBuild MyProject.vcxproj /p:Configutation=Release # x64 Release Build MSBuild MyProject.vcxproj /p:Configutation=Release /p:Platform=Win32 # x86 Release Build
NuGetã¨ã®ç¸æ§
.NET Frameworkã®å ´åNuGetããã¤ã³ã¹ãã¼ã«ããdllã¸ã®ãã¹ãä¾åé¢ä¿ãèªåçã«ããã¸ã§ã¯ããã¡ã¤ã«ã«è¿½å ããã. VC++ã®å ´åã¯ãã¹ã¦æåã§è¨å®ããå¿ è¦ããã.