PIC "error: missing definition"

Help
2008-06-27
2013-03-12
  • Hi,
    I am new to PIC and SDCC, installed both Piklabs as well as SDCC (2.7.0) from Ubuntu 8.04's synaptic package manager. I am trying to compile a basic code for the pic18f2550 device but in vein.

    The code doesn't make sense but this is just to delineate the error SDCC prompts when I try to use any of the C libraries:

    #include <pic18f2550.h>
    #include <delay.h>
    #include <adc.h>

    void main()
    {
           adc_conv();
            delay10tcy(10);
    }

    and the display would be:

    sdcc -mpic16 -p18f2550 -V --debug -I/home/ashwin/Desktop/18f/ -c 18f.c
    + "/usr/bin/sdcpp" -nostdinc -Wall -std=c99 -I"/home/ashwin/Desktop/18f/" -Dpic18f2550 -D__18f2550 -DSTACK_MODEL_SMALL -obj-ext=.o -DSDCC_MODEL_SMALL -DSDCC=270 -DSDCC_pic16 -D__pic16 -I"/usr/bin/../share/sdcc/include/pic16" -I"/usr/share/sdcc/include/pic16" -I"/home/ashwin/Desktop/18f/"  "18f.c"
    + "/usr/bin/gpasm" -DSDCC_MODEL_SMALL -Dpic18f2550 -D__18F2550 -DSTACK_MODEL_SMALL -g -c "18f.asm" -o "18f.o"
    gpasm -c -I/home/ashwin/Desktop/18f/ -w0 18f.asm
    18f.asm:10: warning: directive ignored when debug info is disabled
    18f.asm:277: warning: directive ignored when debug info is disabled
    18f.asm:280: warning: directive ignored when debug info is disabled
    sdcc -mpic16 -p18f2550 -V --debug -Wl-c -Wl-m -I/home/ashwin/Desktop/18f/ -o18f.hex 18f.o
    using default linker script "/usr/share/gputils/lkr/18f2550.lkr"
    missing definition for symbol "_delay10tcy", required by "18f.o"
    missing definition for symbol "_adc_conv", required by "18f.o"

    + "/usr/bin/gplink" -I"/usr/bin/../share/sdcc/lib/pic16" -I"/usr/share/sdcc/lib/pic16"  -c -m  -w -r -o 18f.hex  18f.o  crt0i.o pic18f2550.lib libsdcc.lib

    *** Exited with status: 1 ***

    There are two main things which I did not understand:

    1. warning: directive ignored when debug info is disabled - Why do I get this warning?
    2. missing definition for symbol "_delay10tcy", required by "18f.o"
    missing definition for symbol "_adc_conv", required by "18f.o" - How do I solve this error?

    Have been cracking my head on this from the past 2 days (and nights too), didn't find a closely related post on the forum either so any help is really appreciated.

     
    • Raphael Neider
      Raphael Neider
      2008-06-27

      > sdcc -mpic16 -p18f2550 -V --debug -I/home/ashwin/Desktop/18f/ -c 18f.c
      > + "/usr/bin/sdcpp" -nostdinc -Wall -std=c99 -I"/home/ashwin/Desktop/18f/"
      > -Dpic18f2550 -D__18f2550 -DSTACK_MODEL_SMALL -obj-ext=.o -DSDCC_MODEL_SMALL
      > -DSDCC=270 -DSDCC_pic16 -D__pic16 -I"/usr/bin/../share/sdcc/include/pic16"
      > -I"/usr/share/sdcc/include/pic16" -I"/home/ashwin/Desktop/18f/"  "18f.c"
      > + "/usr/bin/gpasm" -DSDCC_MODEL_SMALL -Dpic18f2550 -D__18F2550 -DSTACK_MODEL_SMALL
      > -g -c "18f.asm" -o "18f.o"
      > gpasm -c -I/home/ashwin/Desktop/18f/ -w0 18f.asm
      > 18f.asm:10: warning: directive ignored when debug info is disabled
      > 18f.asm:277: warning: directive ignored when debug info is disabled
      > 18f.asm:280: warning: directive ignored when debug info is disabled

      These warnings indicate that someone passed --debug to the compiler (thus emitting .line directives in the .asm file) but that the assembler is called without the -d/-g option, thus making it ignore the .line directives.
      Worse: sdcc already called the assembler correctly (+ "/usr/bin/gpasm" [...] -g -c 18f.asm -o 18f.o), your IDE tries to be clever by calling it again --- without required/useful arguments.

      > sdcc -mpic16 -p18f2550 -V --debug -Wl-c -Wl-m -I/home/ashwin/Desktop/18f/ -o18f.hex 18f.o
      > using default linker script "/usr/share/gputils/lkr/18f2550.lkr"
      > missing definition for symbol "_delay10tcy", required by "18f.o"
      > missing definition for symbol "_adc_conv", required by "18f.o"
      >
      > + "/usr/bin/gplink" -I"/usr/bin/../share/sdcc/lib/pic16"
      > -I"/usr/share/sdcc/lib/pic16"  -c -m  -w -r -o 18f.hex  18f.o  crt0i.o pic18f2550.lib libsdcc.lib

      The missing definitions stem from the fact that the required libraries (libc18f.lib and libio18f2550.lib) are not mentioned in the linker's command line. You might be able to add them to the required libraries in some dialog box, I do not know.

      BTW: A simple
          sdcc -mpic16 -p18f2550 18f.c
      would have succeeded / works for me (at least in recent versions, try a snapshot).

      HTH,
      Raphael

       
    • Phew! a little basic would save you a lot of time. Thanks Raphael, your lead really did help me out. Here is the solution for those newbies who would face the same problem:

      In Piklabs,
      1. select Project->Project options...
      2. In the toolchain tab, selct compiler and change configuration option to 'Custom', click on -c and press remove.
      3. In the Assembler tab, change the configuration to 'Custom', click on remove all, type -v in the edit box and press add.
      4. Do the same for Linker, click on OK and you are ready to go!

      Don't consider doing this if your project has multiple source files. If you insist on doing so, you will have to change the Linker option for each and every project which can get quite messy. Other option would be to compile all you source files into a library and then call the functions, I am yet to figure out how to do so. Hope to get some help from the guys in the forum. :)