Johan
Reged: Oct 16 2003
Posts: 108
Loc: Sweden
|
|
Hello.
Im trying to compile a simple program using the lcd rutines that comes with HT-PIC.
I have moved lcd.h,lcd.c and also delay.h,delay.c from the sample dir to the include dir.
I have included the lcd.h file and lcd.c file in my project.
The complier doesn't say anyting that the include files is missing, becuase they are there, but when linking, HLINK.EXE generates "undefined symbols" errors on the "::?a_lcd_goto" and "::?_a_lcd_putch" witch is only called internally from the lcd.c file.
If i only include the lcd.h file, i get undefined symbols on all functions(lcd_init,lcd_clear,e.t.c.) i call from the main sourcefile.
Why? What can i do about it?
Hope you understands my problem.
winXP,complier v8.00PL4, using HPDPIC.
//Johan
|
Juergen Weiss
Reged: Oct 16 2003
Posts: 1
|
|
Hi Johan,
I suggest to make a special directory which contains all your programm files (delay.h, delay.c, lcd.h, lcd.c and the file containing the main loop; e.g.: project.c.
Now include only the .h - files with #include "xyz.h" ... (do not use )in project.c.
Build a project under MPLAB 'Project' --> 'New Project'.
In the generated project file include your source code files: project.c, delay.c, lcd.c and let picc compile and link them all together.
If you now comiple your files with F10 it should work.
Bye
Juergen
>Hello.
>
>Im trying to compile a simple program using the lcd rutines that comes with HT-PIC.
>I have moved lcd.h,lcd.c and also delay.h,delay.c from the sample dir to the include dir.
>
>I have included the lcd.h file and lcd.c file in my project.
>The complier doesn't say anyting that the include files is missing, becuase they are there, but when linking, HLINK.EXE generates "undefined symbols" errors on the "::?a_lcd_goto" and "::?_a_lcd_putch" witch is only called internally from the lcd.c file.
>
>If i only include the lcd.h file, i get undefined symbols on all functions(lcd_init,lcd_clear,e.t.c.) i call from the main sourcefile.
>
>Why? What can i do about it?
>
>Hope you understands my problem.
>
>
>winXP,complier v8.00PL4, using HPDPIC.
>
>//Johan
|
Tomasz
Reged: Oct 16 2003
Posts: 313
|
|
Including *.h is not enough. You must add all *.c used by your code to the -project-. Try Make-Source files list->Insert. Also avoid adding *.c files using #include directive in your source. The right place to do it is a project.
>
>If i only include the lcd.h file, i get undefined symbols on all functions(lcd_init,lcd_clear,e.t.c.) i call from the main sourcefile.
>
>Why? What can i do about it?
>
The *.h file only declares, that a function will be somewhere. It opens you the way to use it, but tells notging about how to compile it. The *.c file in other hand defines function code, but including it in many places will repeat deffinition causing errors. If you see undefined symbols it means:
- you have made a typing error in some names. It will appear together with "function declared implict int" warning, if warnings are enabled;
- you have forgoten to add a library or a source, which contains missing definition. This file might contain functions not implictly called by your code, but might be needed by some of utility libraries you use;
hope it will help.
Tomasz Sztejka.
|
Johan
Reged: Oct 16 2003
Posts: 108
Loc: Sweden
|
|
>Including *.h is not enough. You must add all *.c used by your code to the -project-. Try Make-Source files list->Insert. Also avoid adding *.c files using #include directive in your source. The right place to do it is a project.
>
>>
>>If i only include the lcd.h file, i get undefined symbols on all functions(lcd_init,lcd_clear,e.t.c.) i call from the main sourcefile.
>>
>>Why? What can i do about it?
>>
> The *.h file only declares, that a function will be somewhere. It opens you the way to use it, but tells notging about how to compile it. The *.c file in other hand defines function code, but including it in many places will repeat deffinition causing errors. If you see undefined symbols it means:
> - you have made a typing error in some names. It will appear together with "function declared implict int" warning, if warnings are enabled;
> - you have forgoten to add a library or a source, which contains missing definition. This file might contain functions not implictly called by your code, but might be needed by some of utility libraries you use;
>
>hope it will help.
>
> Tomasz Sztejka.
>
I moved LCD.c,h and delay.c,h to my sourcefile direcory.
I include "lcd.h" and "delay.h" and i have added lcd.c and delay.c into the source file list.
But when making the project i get the same error:
::undefined symbols: (error)
::?a_lcd_goto (LCD.OBJ) (error)
::?_a_lcd_putch (LCD.OBJ) (error)
Im using the standard Lcd.c and delay.c that comes with ht-picc. Heres my code:
>////Code starts here ///
#include <pic.h>
#include <stdio.h>
#include "delay.h"
#include "lcd.h"
__CONFIG(0x3F14h);
#define XTAL 20000000 // crystal frequency - 20MHz
#define ICLK (XTAL/4) // crystal is divided by four
void main()
{
TRISA = 0b00000000;
TRISB = 0b00000000;
//CMCON = 0b00000111; // for 16F628
lcd_init();
DelayMs(250);
lcd_clear();
DelayMs(250);
while (1)
{
lcd_puts("Welcome!");
DelayMs(255);
lcd_clear();
DelayMs(255);
}//end while
}//end main
>////Code ends here ///
|
Tomasz
Reged: Oct 16 2003
Posts: 313
|
|
>I moved LCD.c,h and delay.c,h to my sourcefile direcory.
>I include "lcd.h" and "delay.h" and i have added lcd.c and delay.c into the source file list.
>But when making the project i get the same error:
>
>::undefined symbols: (error)
>::?a_lcd_goto (LCD.OBJ) (error)
>::?_a_lcd_putch (LCD.OBJ) (error)
>
I could not duplicate your problem. Made a project, added lcd.c and delay.c, cut&paste your code and all linked ok (picc 7.87pl2). Both with HPDPIC and MPLAB. Try doing the same from MPLAB, not from HPDPIC. It needs some job at the beginning with configuring MPLAB, but then it is much more user friendly.
|
|