我們有一個交叉編譯的visual studio Makefile項目。我們已經必須引入一個solution similar to this以使它識別編譯器錯誤。 IE瀏覽器。我們引入了一個Perl腳本來解析GCC的輸出,並將其轉換爲Visual Studio可以理解的形式。如果我們聲明:Visual Studio無法識別Makefile項目中的GCC鏈接器錯誤
int succ = thisRandomFunction(userPointer, 1, 1);
沒有定義thisRandomFunction
那麼我們將得到鏈接器錯誤:
1> ./program.a(taskqueue.o): In function `TaskQueueAdd': 1>
D:\Git\program\taskqueue.c(94,1) : undefined reference to `thisRandomFunction' 1>
collect2: ld returned 1 exit status 1> make: *** [program.exe] Error 1
但視覺工作室實際上並不承認這是一個錯誤。同樣的問題在Visual Studio的C++控制檯程序有鏈接錯誤:
1> TestUndefinedReference.cpp
1>TestUndefinedReference.obj : error LNK2019: unresolved external symbol "int __cdecl something(int)" ([email protected]@[email protected]) referenced in function _main
1>D:\Projects\New folder\TestUndefinedReference\Debug\TestUndefinedReference.exe : fatal error LNK1120: 1 unresolved externals
通過使用該轉換器:
sub parseLinkerError
{
my $str = $_[0];
my $find = "undefined reference to";
my $replace = "error LNK2019: unresolved external symbol";
$str =~ s/$find/$replace/g;
return $str
}
我們可以將此轉換:
1> d:\Git\program/taskqueue.c:94: undefined reference to `thisRandomFunction'
這個
1> D:/Git/eV+/program/taskqueue.c(94,1) error LNK2019: unresolved external symbol `thisRandomFunction'
B這不足以欺騙Visual Studio鏈接器錯誤解釋器。 它看到鏈接器錯誤的最低要求是什麼?有沒有解決方案可以直接解析文本?
總而言之,你的樣本失敗的閱讀你的鏈接代碼項目後,一個很好的問題(請原諒我以前的怪癖)。你應該讓這個更加突出,在一個簡短的總結中解釋,爲你的問題得到一個簡潔的答案。我自己沒有一個,對不起。 –
您是否嘗試添加從'/'到'\'的斜槓轉換? $ str =〜s/\ // \\ /; –
@JimBlack是的,我們轉換「\」。調整問題 –