Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Warning: module holds reference to undefined symbol (http://www.chiefdelphi.com/forums/showthread.php?t=103058)

Andrew Schreiber 17-02-2012 01:32

Warning: module holds reference to undefined symbol
 
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

Re: Warning: module holds reference to undefined symbol
 
Quote:

Originally Posted by Andrew Schreiber (Post 1128577)
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

Re: Warning: module holds reference to undefined symbol
 
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

Re: Warning: module holds reference to undefined symbol
 
Quote:

Originally Posted by wireties (Post 1128629)
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:

Code:

#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();
}

Code:

#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

Re: Warning: module holds reference to undefined symbol
 
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

Re: Warning: module holds reference to undefined symbol
 
Quote:

Originally Posted by wireties (Post 1128693)
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

Re: Warning: module holds reference to undefined symbol
 
In this thread 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

Re: Warning: module holds reference to undefined symbol
 
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

Re: Warning: module holds reference to undefined symbol
 
Quote:

Originally Posted by Andrew Schreiber (Post 1128697)
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

Re: Warning: module holds reference to undefined symbol
 
Quote:

Originally Posted by wireties (Post 1128705)
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

Re: Warning: module holds reference to undefined symbol
 
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

Re: Warning: module holds reference to undefined symbol
 
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

Re: Warning: module holds reference to undefined symbol
 
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

Re: Warning: module holds reference to undefined symbol
 
1 Attachment(s)
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

Re: Warning: module holds reference to undefined symbol
 
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.


All times are GMT -5. The time now is 12:43.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi