Thread: ERROR
View Single Post
  #5   Spotlight this post!  
Unread 26-02-2005, 17:36
Alex1072 Alex1072 is offline
Registered User
AKA: Alex
#1072 (Harker Robotics Team)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: San Jose
Posts: 110
Alex1072 is an unknown quantity at this point
Send a message via AIM to Alex1072 Send a message via Yahoo to Alex1072
Re: ERROR

Quote:
Originally Posted by amateurrobotguy
I have made some progress. I got rid of all the error right down to the last lines:
MPLINK 3.40, Linker
Copyright (c) 2003 Microchip Technology Inc.
Error - could not find definition of symbol 'ceil' in file 'D:\Robot\MyFiles\user_routines.o'.
Errors : 1

All i did was this:

/************************************************** *****************************
* FILE NAME: user_routines.c <FRC VERSION>
*
* DESCRIPTION:
* This file contains the default mappings of inputs
* (like switches, joysticks, and buttons) to outputs on the RC.
*
* USAGE:
* You can either modify this file to fit your needs, or remove it from your
* project and replace it with a modified copy.
*
************************************************** *****************************/

#include "ifi_aliases.h"
#include "ifi_default.h"
#include "ifi_utilities.h"
#include "user_routines.h"
#include "printf_lib.h"
#include "user_Serialdrv.h"
#include <math.h>

extern unsigned char aBreakerWasTripped;

/*** DEFINE USER VARIABLES AND INITIALIZE tHEM HERE ***/

/* EXAMPLES: (see MPLAB C18 User's Guide, p.9 for all types)
unsigned char wheel_revolutions = 0; (can vary from 0 to 255)
unsigned int delay_count = 7; (can vary from 0 to 65,535)
int angle_deviation = 142; (can vary from -32,768 to 32,767)
unsigned long very_big_counter = 0; (can vary from 0 to 4,294,967,295)
*/
double ceil(double x);
double pow(double x, double y);

See two last lines. Am I going down the right path? If so, what is causing the error then?

Those two lines that you added are exactly what would have been in math.h. Unfortunatly you also need the actual code of the functions. The way libraries usually work in c is that you have a .h file that tells the compiler all the functions and variables defined in the library, and you have a .o file which contains the compiled code. The way a compiler works is that it takes code and then terns each file into a .o file. The .o file contains "object code". The oject code is an intermediary step between the source code and the actual .hex file. The linker then combines all the .o files into one .hex file. The error that you're getting now is because the compiler does sees all the definitions and compiles the user_routines file assuming that the ceil and pow functions exist. When the linker tries to link the object files though, it doesn't find the actual code for the ceil and pow functions. In order for this to work you have to make it so that MPLAB uses math.o as part of the project and links it in along with your code. Alternativly, you can find the source code to math.o, which would be math.c, and compile it as part of your project. Then the compiler would first compile math.c into a new math.o, and then the linker coud use that to create the .hex file.
__________________
--------------------------------------
Alex
President
Team 1072 Harker Robotics