Sometimes, when I try running the code on the robot, it refuses to transfer over during debug mode because of “unresolved references”. It then displays a popup containing the semi-garbled names of various functions or classes that I placed in my header files but forgot to actually write in the corresponding .cpp file.
It’s relatively easy to catch them at this stage, but is there some way to catch these errors at compile time? It’s frustrating to have to wait until I’m next to a cRIO so I can catch these sorts of mistakes, instead of being able to detect them at home while coding.
I did find a Stack Overflow thread which listed a few compiler flags which should be able to do what I want, but I couldn’t figure out how to apply them to my WindRiver project.
Of course, vxworks provides some of those unresolved symbols, and what is useful to you is determining whether your program uses symbols that vxworks does not provide.
Potentially you could construct a list of symbols provided by vxworks (adding new ones that your code uses as needed), filter those out, and if any are left produce an error in your build scripts.
The following shows how to filter out known vxworks symbols (assuming you list them, 1 per line, in vxworks_syms.txt):
If you wanted to add those build options to your project, all you have to do is (in Wind River) go to your project properties (right click on project and click the Properties option) and then to your Build Properties. Under one of the tabs (I forget which one) there will be a bunch of GCC configuration stuff. There is a box with a bunch of compiler args. All you have to do is add yours in there.
I couldn’t find the powerpc-wrs-vxworks-readelf program on Linux, but I did discover that the FRC_UserProgram.out file is actually a readable text file, so I could search for the undefined symbols directly from it.
In case anybody else has the same problem as I did, I wrote up a quick Python script to find the undefined symbols from it. (see attached). It should be cross-platform, and should work on at least Python 2.7 and probably Python 3.x.
It’s not quite compile time, but it worked for me.
the powerpc-wrs-vxworks-readelf program should be installed with windriver on windows, where you can use cygwin to get the other parts (a shell, awk, and grep).
On linux, you can use the readelf from a binutils compiled with multi-target support, or a custom build bintuils for the powerpc-wrs-vxworks target. See http://www.chiefdelphi.com/forums/showthread.php?t=109385 for some info on that (and building your own gcc). Note that building binutils (which includes readelf) for powerpc-wrs-vxworks does not need the vxworks headers, nor does it require any patching. It should just work.