環(huán)境
| OS | CPU | Tool |
|---|---|---|
| Win10 | x64 | VS2015+LLVM+VSCode |
步驟
- 安裝VS2015(或者其他版本的VS)
- 安裝LLVM
- 安裝VSCode
- 在VSCode中搜索插件Code Runner并安裝
- 重啟VSCode
問題集
1. 終端亂碼
- 現(xiàn)象:終端輸出亂碼
- 原因:
- 解決:把首選項的
"code-runner.runInTerminal"改為true,重啟VSCode
如何指定生x86還是x64
給clang命令添加選項-target,值為
x86:i686-pc-windows-msvc
x64:x86_64-pc-windows-msvc
2. C++編譯警告(未解決)
- 現(xiàn)象:LNK4217警告
XXX.o : warning LNK4217: 本地定義的符號 ___std_terminate 在函數(shù) "int `public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)'::`1'::dtor$3" (?dtor$3@?0???1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ@4HA) 中導入
- 原因:???
XXX.o : warning LNK4217: 本地定義的符號 ___std_terminate 在函數(shù)std::basic_string::~basic_string()導入 - 解決:???
3. C++鏈接錯誤
- 現(xiàn)象:error LNK2019
error LNK2019: 無法解析的外部符號 __imp____RTDynamicCast
error LNK2019: 無法解析的外部符號 __imp____RTtypeid
- 原因:
沒有連接RTTI相關(guān)庫 - 解決:
添加庫文件"vcruntime.lib"
#pragma comment(lib,"vcruntime.lib")