Please help with a very stubborn linker error

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Please help with a very stubborn linker error

4,173 Views
dwhite
Contributor I
I am getting a L1822: error that I just can't explain. I had been able to build this application earlier this morning and have tried to put everything back to that state of the last good build but I can't get rid of this error. Here is the error message...
"Link Error   : L1822: Symbol calver in file C:\firmware\duramax\63752-03\sixgun\DMLBZ\DMLBZ_Data\P&E_ICD\ObjectCode\powerup.c.o is undefined"
 
 The symbol that it says is undefined is in my calibrations.h file and looks like this...
 
#ifdef DECLARE
#define EXTERN
#else
#define EXTERN extern
#endif
 
EXTERN const   uByte  calver[]
#ifdef DECLARE
 =          "Calibration V00.00.06.00"
#endif
;
#undef DECLARE
#undef EXTERN
This header file is included in main.c like this...
#define DECLARE  //locate data
#include "calibrations.h"
The file that can't find the calver symbol is powerup.c and it includes the file like this...
#include "calibrations.h"
Is there something wrong with this "#define DECLARE" method (It worked yesterday) or is there some way I could have broken the linker when I added some files and then removed them that could cause this? I have read the manuals and tried some experiments with paths and link order that haven't helped.
 
Please help....I've been fighting with this for about 4 hours now and don't know what else to try.
 
-Dan White
Labels (1)
0 Kudos
4 Replies

342 Views
BlackNight
NXP Employee
NXP Employee
Hello,
I would first to a menu Project > Remove Object code to have a clean table.
Next thing even to delete the intermediate files in the project subfolder, named 'projectname'_Data.

Next I would check the compiler preprocessing output for powerup.c: for this you could right-mouse-click on the source file in the editor and do a 'preprocess': just to check that the logic you describe below is really working as you desire. Maybe you have other includes screwing up your logic below?

Hope this helps,
Erich
0 Kudos

342 Views
dwhite
Contributor I

I tried removing the object code and nothing changed.

I reviewed the preprocess output and don't see anything wrong. The symbol calver shows like this...

/*       36 */  extern const uByte calver [ ]
/*       40 */  ;

and another string that works from a different .h file looks the same like this...

/*       28 */  extern const uByte swver [ ]
/*       32 */  ;

In this .c file that can't find the symbol calver, swver works fine. Here is how they are used...

  cputs((const char *)swver);

  cputs((const char *)calver);

Why would one of these strings work in one .h file but not the other? Could there be something about this .h file or link order that would cause this problem? I tried removing the .h file with calver and adding it back into the project, but that didn't change anything.

Still lost....please help.

0 Kudos

342 Views
CrasyCat
Specialist III
Hello
 
According to my understanding you want to define the variable calver in in main.c?
The linker is notifying you that it does not find any definition for the variable calver.
 
Can you preprocess the file main.c. How is calver defined there?
 
CrasyCat
0 Kudos

342 Views
dwhite
Contributor I

Ahhh.... now we're getting somewhere.... calver in main.pre is an external reference and does not contain the data but swver has the data definition. It turns out that one of my new include files had a

#undef DECLARE

in it that was causing the problem when included in calibrations.h but wasn't include elsewhere.

Thanks a lot for the help!


 

 

0 Kudos