Log in

View Full Version : Warning: module holds reference to undefined symbol


Andrew Schreiber
17-02-2012, 01:32
While using Command Based Robot code I am getting the following error for each of my SubSystems

Warning: module [what I guess is an address in the symbol table] holds reference to undefined symbol [some number]CommandBase[Hex Value][name of symbol]

It then unloads the FRC_UserProgram.out causing a "No Robot Code" error.

Now the weird part, on a whim I changed the reference name (via the refactor menu) to something different. The error never changed. I searched for every instance the old name and none were found. This makes me question whether the updated code is being put onto the robot.

Any advice is appreciated.

wireties
17-02-2012, 06:55
While using Command Based Robot code I am getting the following error for each of my SubSystems

Warning: module [what I guess is an address in the symbol table] holds reference to undefined symbol [some number]CommandBase[Hex Value][name of symbol]

It then unloads the FRC_UserProgram.out causing a "No Robot Code" error.

Now the weird part, on a whim I changed the reference name (via the refactor menu) to something different. The error never changed. I searched for every instance the old name and none were found. This makes me question whether the updated code is being put onto the robot.

Any advice is appreciated.

I'm not sure what help I can be - we don't use the command-based robot code. No doubt you know this but for the students out there - when we load kernel modules we use a dynamic linking loader but it is a single pass linker unlike the multi-pass linker we use to combine object modules and libraries form the command line. The process is much like loading a kernel module in Linux or a dynamic driver in Solaris.

So you are loading a kernel module that has a symbol in it that cannot be resolved against the symbol tables of all modules (and the kernel) already in memory. From your description, the symbol is a mangled C++ symbol.

When you build the command-based code, do you need to pre-link a library with your application code (with a -l parameter on the linker command line)? I will look at the command-based stuff and get back to you.

HTH

wireties
17-02-2012, 07:05
The command-based robot does not link to any extra libraries, only to WPILib.a, so that is not the problem. Do you include a customized version of CommandBase.cpp in your project? I see that class has 3 static members - init, OI and examplesubsystem)? Do you have instances of all 3 declared somewhere?

Andrew Schreiber
17-02-2012, 09:00
The command-based robot does not link to any extra libraries, only to WPILib.a, so that is not the problem. Do you include a customized version of CommandBase.cpp in your project? I see that class has 3 static members - init, OI and examplesubsystem)? Do you have instances of all 3 declared somewhere?

CommandBase.cpp has been modified to look like:

#include "CommandBase.h"

#include "Commands/Scheduler.h"


CommandBase::CommandBase(const char *name) : Command(name) {
}

CommandBase::CommandBase() : Command() {
}

// Initialize a single static instance of all of your subsystems to NULL
OI* CommandBase::oi = NULL;
DriveTrain *CommandBase::chassis = NULL;
Elevator *CommandBase::elevator = NULL;
Intake *CommandBase::intake = NULL;
Shooter *CommandBase::shooter = NULL;

void CommandBase::init() {
// Create a single static instance of all of your subsystems. The following
// line should be repeated for each subsystem in the project.
//examplesubsystem = new ExampleSubsystem();
chassis = new DriveTrain();
elevator = new Elevator();
intake = new Intake();
shooter = new Shooter();

oi = new OI();
}


#ifndef COMMAND_BASE_H
#define COMMAND_BASE_H

#include "Commands/Command.h"
#include "Subsystems/DriveTrain.h"
#include "Subsystems/Elevator.h"
#include "Subsystems/Intake.h"
#include "Subsystems/Shooter.h"
#include "OI.h"


/**
* The base for all commands. All atomic commands should subclass CommandBase.
* CommandBase stores creates and stores each control system. To access a
* subsystem elsewhere in your code in your code use CommandBase.examplesubsystem
*/
class CommandBase: public Command {
public:
CommandBase(const char *name);
CommandBase();
static void init();
// Create a single static instance of all of your subsystems
static DriveTrain *chassis;
static Elevator *elevator;
static Intake *intake;
static Shooter *shooter;
static OI *oi;
};

#endif

wireties
17-02-2012, 09:23
That looks correct to me. Are all your subsystem classes complete or stubbed out?

Maybe try commenting out your additions till the module will load?

Andrew Schreiber
17-02-2012, 09:33
That looks correct to me. Are all your subsystem classes complete or stubbed out?

Maybe try commenting out your additions till the module will load?

They are indeed all stubbed out, the Create New SubSystem option in the context menu on the project tends to create fully stubbed out subclass of SubSystem.

I attempted the commenting out solution, none of the modules would load.

Jared Russell
17-02-2012, 09:38
In this thread (http://www.chiefdelphi.com/forums/showthread.php?t=80540) from a couple years ago the poster had a similar problem. For him, doing a clean reinstallation of WindRiver and all the updates fixed the issue. I would try installing WindRiver to its default directory for good measure.

wireties
17-02-2012, 09:40
Time to check with the author I reckon - perhaps try the nmppc utility and see if you can identify the unmangled symbol name? Is the 4 Feb update required to support the command-based templates? And if so, is your development environment up to date?

wireties
17-02-2012, 09:44
They are indeed all stubbed out, the Create New SubSystem option in the context menu on the project tends to create fully stubbed out subclass of SubSystem.


Where in the project do you right-click? I don't see the "Create New SubSystem" option.

Andrew Schreiber
17-02-2012, 09:45
Where in the project do you right-click? I don't see the "Create New SubSystem" option.

There is additional software you have to install (see the WPILib Cookbook for instructions). You click on the project name.

wireties
17-02-2012, 10:11
Hey - we do something like this but it is all home brewed. It cleanly separates the behaviors into classes/tasks though and uses a message passing mechanism to isolate each function. It makes life much easier for the student programmers, they can focus on simple tasks as if they were a single program.

PM me an e-mail address and we'd be glad to share the current code with you.

scottbot95
06-02-2013, 19:26
have you declared all the static members somewhere other than the class definition? it's a dumb problem with c++ but if you dont, the compiler wont actually create a symbol for the static class member.

bob.wolff68
07-02-2013, 00:57
I'll throw my 2 cents in. We've had some whacky problem in the past which were never fully explained, but sometimes doing a Project->Clean... will rinse out the garbage and get you back to sanity. I would suggest doing it as there should be no ill effects from a clean at all and only potential up-side.

bob

enrique
10-02-2013, 02:59
I'm having the same error. I thought it was because of a class I made for a sensor, but I removed the class and the error continues. Warning: module holds reference to undefined symbol round. In debug I get the screen attached.

enrique
10-02-2013, 10:46
Don't know if this helps, but on my error it had to do with the math.h include. Even though winriver has it and it has the round feature. I think the crio has something different. Either ways I made my own round function and it worked fine. Your error is wpilib related. I'm thinking maybe if you run the winriver update and format the crio, maybe the wpilibs will be in sync.

kylelanman
10-02-2013, 15:29
One problem we faced a couple times this year was not providing an implementation of pure virtual functions in our subsystems and commands.

The two that come to mind are if your using a PIDSubsystem you have to implement.

virtual double ReturnPIDInput();
virtual void UsePIDOutput(double output);

In normal commands we implemented each command in it's own .h file.

We found our selves constantly leaving out implementations of empty methods.

ex.

~ArmUpCommand();
instead of
~ArmUpCommand() {}

and

Execute();
instead of
Execute() {}

The best way to narrow it down it down that we found is to comment all the subsystems and uncomment them one at a time until you can narrow it down to a particular subsystem or command.

If you'er still stumped then you can post that command or subsystem and the CD community can hopefully help you out.