![](/img/trans.png)
[英]Visual studio 2017 - error MSB6006: “CL.exe” exited with code 2
[英]Error MSB6006 “CL.exe” exited with code 2 in compile in visual studio c++
我在c ++控制台項目上工作。 該項目在msmpisdk平台中具有。 當我在Visual Studio 2019中編譯時,發生以下錯誤:
“嚴重性代碼描述項目文件行抑制狀態...錯誤MSB6006” CL.exe“退出,代碼為2。...C:\\ Program Files(x86)\\ Microsoft VisualStudio \\ 2019 \\ Enterprise \\ MSBuild \\ Microsoft \\ VC \\ v160 -\\ Microsoft.CppCommon.targets429。”
我檢查了我的代碼,看來還可以,還檢查了項目的ref lib,看來還可以。
我在網上搜索。
但發生相同的錯誤,我的代碼無法編譯。
最后我發現了問題。
#include "iostream" class myclass1 { public: int _AMethod() { return 55; } }; int main() { myclass1* myVariable; int x = 0; if (x == 0) { myVariable = (myclass1*)malloc(sizeof(myclass1) * 5); //myVariable = init(); } if (x == 0) { myVariable->_AMethod(); } }
現在在編譯時發生此錯誤:錯誤MSB6006“ CL.exe”退出,代碼2。
通過定義init可以輕松解決此錯誤,如下所示:
#include "iostream" class myclass1 { public: int _AMethod() { return 55; } }; int main() { myclass1* myVariable=(myclass1*)malloc(sizeof(myclass1) * 5); int x = 0; if (x == 0) { //myVariable = (myclass1*)malloc(sizeof(myclass1) * 5); //myVariable = init(); } if (x == 0) { myVariable->_AMethod(); } }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.