Symbol defined or not, that’s the question

I just ran into this problem: I know I have this file in my project, but still the linker complains that it cannot find the symbols: “Symbol X is undefined”? It must be something obvious, but somehow I cannot see it?

Symbol Undefined Linker Error Message

Symbol Undefined Linker Error Message

I know all these things are in my Events.c file, and it is part of my project:

Events.c in my project

Events.c in my project

The linker does not have Events_c.obj file listed in the Console view. The console at least tells me what the linker is using:

"C:/Freescale/CW MCU v10.2/MCU/prog/linker" -ArgFile"SRB.args" -O"SRB.abs"
"C:/Users/Erich Styger/Data/HTA/CW/wsp_Intro/SRB_Ref/Project_Settings/Linker_Files/ProcessorExpert.prm"
Command Line: '-ArgFile"SRB.args" -O"SRB.abs"'
....

So the *.args file has the arguments. The external .args file helps the linker to deal with the host operating system command line length limitiation. Inspectinig the .args file indeed does not have Events_c.obj listed.

So indeed, the file is not part of my build. Maybe I screwed up something? Yes, I was working on build configurations, have added configurations and removed them again. Maybe this caused the problem? And yes, indeed, I noticed the tiny icon decorator change for my file, indicating that my file indeed has special settings:

Using the ‘Reset to Default…’ is removing the settings:

Reset to Default...

Reset to Default...

Now I see as well the cause of the troubles: the file is excluded from the build:

File excluded from build

File excluded from build

Ah, OK! I did not pay attention to the icon decorator. Now the fix is easy. The file is part of my project, but not part of my build :-(. Although including means you have to select ‘Exclude‘ again:

Exclude from build

Exclude from build

This gives me the following dialog, where I need to un-check it to have it back included in the build:

Exclude from build dialog

Exclude from build dialog

Another ways is to use the ‘Properties’ menu on that file:

File Properties

File Properties

Note: In case you exclude the Batch Burner File (burner. bbl) from the build, then the S19 file will not be generated. So if you want that S19 file, and it is not built, you might check if you have excluded the burner.bbl from the build configuration.

Happy Excluding & Including 🙂

5 thoughts on “Symbol defined or not, that’s the question

  1. Pingback: Icon and Label Decorators in Eclipse | MCU on Eclipse

  2. Hello Erich, I really found this site helpful and well documented about the use of codewarrior. I´m having an issue with the error Symbol undefined but is not related to the cause that you expose here. Maybe after all this time did you have the same error from different source? or did you found another way to sort out with it?

    I´m working with JS16

    Thanks

    Like

    • The JS12 really should not matter, and CodeWarrior for MCU10 is Eclipse, and this is really not CW specific.
      What I have described in this article is basically that the linker does not find that symbol, because it is not present somehow.
      Make sure it is not static if you are using in it from another file. And really check that the file having that symbol is compiled and linked.
      I hope this helps,
      Erich

      Like

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.