We have a cross compiled visual studio Makefile project. We have already had to introduce a solution similar to this to get it to recognize compiler errors. Ie. We have introduced a Perl script to parse the output from GCC and convert it into a form that Visual studio will understand. If we declare:
int succ = thisRandomFunction(userPointer, 1, 1);
with no definition for thisRandomFunction
then we will get the linker error:
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
But visual studio doesn't actually recognize this as an error. A Visual Studio C++ console program with the same problem has the linker error:
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
By using this converter:
sub parseLinkerError
{
my $str = $_[0];
my $find = "undefined reference to";
my $replace = "error LNK2019: unresolved external symbol";
$str =~ s/$find/$replace/g;
return $str
}
We can convert this:
1> d:\Git\program/taskqueue.c:94: undefined reference to `thisRandomFunction'
into this
1> D:/Git/eV+/program/taskqueue.c(94,1) error LNK2019: unresolved external symbol `thisRandomFunction'
But this isnt enough to trick the visual studio linker error interpreter. What are the minimum requirements for it to see a linker error? Are there any solutions that can work without directly parsing the text?
According to the documentation...
The format of the output should be:
{filename (line# [, column#]) | toolname} :
[any text] {error | warning} code####: localizable string
Where:
For example:
C:\sourcefile.cpp(134) : error C2143: syntax error : missing ';' before '}'
LINK : fatal error LNK1104: cannot open file 'somelib.lib'
D:/Git/eV+/program/taskqueue.c(94,1) error LNK2019: unresolved external symbol `thisRandomFunction'
^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With