Visual Studio无法识别Makefile项目中的GCC链接器错误

Fan*_*Fox 5 visual-studio-2015

我们有一个交叉编译的visual studio Makefile项目.我们已经不得不引入类似于此解决方案来使其识别编译器错误.IE浏览器.我们引入了一个Perl脚本来解析GCC的输出并将其转换为Visual Studio将理解的形式.如果我们宣布:

int succ = thisRandomFunction(userPointer, 1, 1);
Run Code Online (Sandbox Code Playgroud)

如果没有定义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
Run Code Online (Sandbox Code Playgroud)

但是Visual Studio实际上并不认为这是一个错误.具有相同问题的Visual Studio C++控制台程序具有链接器错误:

1>  TestUndefinedReference.cpp
1>TestUndefinedReference.obj : error LNK2019: unresolved external symbol "int __cdecl something(int)" (?something@@YAHH@Z) referenced in function _main
1>D:\Projects\New folder\TestUndefinedReference\Debug\TestUndefinedReference.exe : fatal error LNK1120: 1 unresolved externals
Run Code Online (Sandbox Code Playgroud)

通过使用此转换器:

sub parseLinkerError
{
    my $str = $_[0];
    my $find = "undefined reference to";
    my $replace = "error LNK2019: unresolved external symbol";
    $str =~ s/$find/$replace/g;
    return $str
} 
Run Code Online (Sandbox Code Playgroud)

我们可以转换这个:

1>  d:\Git\program/taskqueue.c:94: undefined reference to `thisRandomFunction'
Run Code Online (Sandbox Code Playgroud)

进入这个

1>  D:/Git/eV+/program/taskqueue.c(94,1) error LNK2019: unresolved external symbol `thisRandomFunction'
Run Code Online (Sandbox Code Playgroud)

但这并不足以欺骗visual studio链接器错误解释器.查看链接器错误的最低要求是什么?是否有任何解决方案可以在不直接解析文本的情况下工作?

Moo*_*uck 1

根据文档...

输出的格式应该是:

{filename (line# [, column#]) | toolname} : 
[any text] {error | warning} code####: localizable string 
Run Code Online (Sandbox Code Playgroud)

在哪里:

  • {一| b} 是 a 或 b 中的一个选择。
  • [ccc] 是可选字符串或参数。

例如:

C:\sourcefile.cpp(134) : error C2143: syntax error : missing ';' before '}'
LINK : fatal error LNK1104: cannot open file 'somelib.lib'
Run Code Online (Sandbox Code Playgroud)


您的示例失败,因为它缺少必需的冒号

D:/Git/eV+/program/taskqueue.c(94,1) error LNK2019: unresolved external symbol `thisRandomFunction'
                                    ^
Run Code Online (Sandbox Code Playgroud)