Go to Post ...the list of the things we want to get done in the off-season has grown to such a length that I have to take off my shoes and socks to count them...and I think I may need to grow a few more toes soon. - StephLee [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-06-2005, 22:10
Alex829's Avatar
Alex829 Alex829 is offline
Registered User
FRC #0829
 
Join Date: Jun 2005
Location: Indiana
Posts: 5
Alex829 is an unknown quantity at this point
Cool printf could not find definition

Error msg:

Error - could not find definition of symbol 'printf' in file 'C:\Robot\Doomed\user_routines.o'.

before you press that reply button and tell me this question has already been answered you should know I know this already. first thing I did was search the forums. What I got was some stuff bout makings sure stdio.h was being called, make sure build options are correct, and reinstalling the compiler. I did all three of these things and nothing helps.

I am using MPLAB 7.2 if that helps any. and im just trying to get default code to compile right now. My team never really did figure out what the problem was with printf so we just commented out all the statements and moved on. I would like to use this debugging tool becuase it could save hours to know what is being outputted.

One post that I read did have me stumped and I didnt really know how it could help however the next post was the questioner saying thanks and I was left in the dark.

Quote:
Do either of you still have the old compiler installed as well as the new compiler?

It seems like you are linking with an earlier version of the compiler standard library clib.lib.
That's where printf should now be coming from. Older compiler versions didn't have a printf in the library and teams used the IFI version in the project printf_lib as a substitute.
Thanks for any help you can give.

o btw if you wanna look at the the thread this came from:
http://www.chiefdelphi.com/forums/sh...ntf+definition
  #2   Spotlight this post!  
Unread 26-06-2005, 01:23
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,856
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: printf could not find definition

Printf’s are worth getting running. Pardon me since I'm sure you’ve already tried these things. Some of my questions are just to reconfirm where you’re at. Also, stating the obvious might help anyone with the same problem who finds this thread through a future search.

I assume you added the call to printf in user_routines.c?

Do you have the following line defined in user_routines.c?
#include "printf_lib.h" //(only used with pre-v2.4 compilers)
or did you use
#include <stdio.h>

Do you have the include path (C:\mcc18\h) and library path (c:\mcc18\lib) specified under Project _> Build Options… -> Project

In your MPLAB project window is “printf_lib.c” or “printf_lib.h” listed (only used with pre-v2.4 compilers)?

Do you know which version of the C compiler you are running?
(Look at the first line in C:\mcc18\README.C18)

On the machine you are using did you ever install from the original CD shipped with the KOP or EDU kit? That'll beg the question: Did you uninstall all old versions of the C18 compiler before installing v2.4?

To expand on your quote from the other thread...
One of the possible causes of the problem you have occurs when you install the v2.4 C compiler on a PC that already has an older version of the compiler. The compiler is told various places and in a variety of ways where to find the files and libraries to use when compiling a project. Old and new files can get mixed. The programmer in the other post solved his or her problem by uninstalling the C18 compiler and making sure all the files were indeed gone, then installing v2.4 from scratch.

If by chance you are using an older version of the compiler, then the solution is a little different.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 26-06-2005 at 01:58.
  #3   Spotlight this post!  
Unread 26-06-2005, 06:56
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: printf could not find definition

This may or may not make a difference, but a lot of times if something isn't working right at all and I think it should, try the "clean" option. (I think that's what MPLAB calls it. If it isn't, you're looking for the build option which removes all its previous files. Alternatively, you can delete the all the compiler generated files on your own.)

Sometimes the compiler just gets confused or (more often, at least for me) you somehow manage to hit the compile button, then the save button, and the compiler gets an old version of the file, but marks the compile date on the .o as being the new file, so even a plain "build all" just results in the old file being used...

So, try hitting "clean." It doesn't cost anything, at the least.
__________________

  #4   Spotlight this post!  
Unread 26-06-2005, 14:38
Alex829's Avatar
Alex829 Alex829 is offline
Registered User
FRC #0829
 
Join Date: Jun 2005
Location: Indiana
Posts: 5
Alex829 is an unknown quantity at this point
Re: printf could not find definition

First I would like to thank you for a detailed replay.

I looked at the version compiler version in readme.c18 and it says v2.20.
I check to see if MPLab had to correct paths in build options. Those are correct. However when I looked to see if printf_lib.h was included in my project it was no where to be found. and it I looked user_routines.c to see was included in that it said #include <stdio.h> so I dont know what that means. Maybe it means that my compiler isnt working with the default camera code? if that is the case where do I get a newer compiler version?

No other compilers have been installed on this machine. so I dont think that is the problem.

On another note I have a copy of 237s code that they posted on chief delphi to help other progrmmers. Their code has printf statements and compile fine.

Last thing is I have solved my problem a little. I can now compile with printf statements. I redownloaded the default code. I decided I dont really care about camera code and I dont really know I why I downloaded that version any way, probably b/c it is a later version so I thought eh whats the difference. However there must have been a difference b/c it compiled without a problem. so I took the files I wanted from the project I was currently working on and put them into default code project that didnt have camera code and it compiled as well. So I am guessing that the older code was made using a comiler version compatable with mine and the camera code was made using a version my compiler mine was not compatable with.

However I would still like to solve this problem so if I am right I will need to know where to get a newer version of the compiler. If that is the problem at all.

About the "clean" option. That sounds like a good idea but I couldnt find it anywhere. could you elaborate on where I can find it at? Thanks
  #5   Spotlight this post!  
Unread 26-06-2005, 17:32
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: printf could not find definition

Alex,

You will find two different default codes here. One is labeled 2.2 and the other 2.4...

If your default code was referencing <stdio.h>, you were using the V2.4 and if it was referencing printf_lib.h, you were using V2.2...

From your last post it seems that you were using the V2.4 default code with the V2.2 compiler. As you found out, this will not work.

In order to get the V2.4 compiler, you must have your team's "main contact" call FIRST and request a CD. No one here can legally give you a copy.

The "clean" command is under the "project" pull down tab in the IDE.

Regards,

Mike
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #6   Spotlight this post!  
Unread 26-06-2005, 20:56
RbtGal1351's Avatar
RbtGal1351 RbtGal1351 is offline
~La Reina de los Robots~
AKA: Stephanie
FRC #1351 (TKO)
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: San Jose, CA
Posts: 166
RbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to beholdRbtGal1351 is a splendid one to behold
Send a message via AIM to RbtGal1351 Send a message via MSN to RbtGal1351
Re: printf could not find definition

YAHOO!

Ok i had (i hope its past tense) the exact same problem as Alex829...

What I discovered:

- Version 2.2 compiles with the printf statements, and it includes printf_lib.h in the project

- Version 2.4 does NOT compile-- the same error message about printf definitions.
The project does not include printf_lib.h

- Version 2.4 with printf_lib.h and printf_lib.c added to the project: COMPILED!!

- My testing code that was based off of v2.4 with printf statements: Does not compile, the printf definition error message. Does not include printf_lib.h or .c

- My testing code (as above) with printf_lib.c and printf_lib.c added to the project: COMPILED!


I haven't been able to test whether the printfs actually work because i'm at home, and not at the lab with an RC.

So, in short, my (i hope) solution: Add printf_lib.c and printf_lib.h to the PROJECT. (Project -> Add files to project -> Select the file to add)

Does this solve anyone else's problems? (Or create more unexpected ones?)


~Stephanie
__________________
2004 Founding member and Arm leader, 2005 Lead programmer, 2006 Controls leader, 2007 Project Manager/President
Thanks for making FIRST such a great experience for me. I'm no longer on 1351, and I'm not currently planning to mentor team 97, but FIRST has meant so much in getting me to where I am now, in life and at MIT, class of 2011.
I met Billfred! He recognized me!
SVR 04: 11th seed - Highest Rookie Seed - Semifinalists w/ 1120 and 568 - GM Industrial Design Award
SVR 05: Semifinalists w/ 8 and 766
SVR 06: 6th seed - Quarterfinalists w/ 368 and 1072
Davis 06: 1st seed - Quarterfinalists w/ 649 and 100 - KPCB Entrepreneurship Award
SVR 07: 36th seed
David 07: 4th seed - Semifinalists w/ 1280 and 692 - Johnson and Johnson Sportsmanship Award
  #7   Spotlight this post!  
Unread 26-06-2005, 21:40
Alex829's Avatar
Alex829 Alex829 is offline
Registered User
FRC #0829
 
Join Date: Jun 2005
Location: Indiana
Posts: 5
Alex829 is an unknown quantity at this point
Re: printf could not find definition

Thank you all who posted. all information that was given was helpful.
  #8   Spotlight this post!  
Unread 27-06-2005, 10:04
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,856
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: printf could not find definition

There was a transition this past season in the printf implementation that has caused this confusion. There are two different printf’s that can be used depending on the compiler version you are running.

When
you use the older compiler, you must use the IFI printf by including printf_lib.c/.h in your projects. But the flip side of using the older compiler is you cannot use the CMU camera default code, because the camera part won’t execute correctly (however if you don’t use the camera it’ll drive fine – nothing unusual there). The project for the CMU camera version of the default code is setup to pull printf from the standard library, but as Stephanie discovered you can add the IFI printf version to the project and use that instead.
--------
Along with the two major compiler releases that concern FIRST teams there are also two major versions of the FIRST default code, v2.2(no camera) vs. v2.4(CMU camera).
The CMU camera code (v2.4) requires capabilities supplied only by the newer v2.4 compiler, and cannot be used with the older compiler. The older code can, however, be used with the newer compiler.

With the older C18 compilers (pre-v2.4) there was no printf supplied in the standard library (stdio). So for those older compilers IFI kindly wrote a printf, with some limitations, and gave it to us in those printf_lib.c and printf_lib.h files. This printf implementation is still usable, but you should read the header comments in printf_lib.c to understand the limitations. It’s the same as writing your own routine. In fact many teams modified or replaced the IFI printf code to alleviate some of the more glaring issues (buffer overwrite, space hog).

With the C18 v2.4 compiler special release to FIRST teams printf was included in the standard library, so the IFI version of printf was no longer necessary. The new version works better, but still has a few limitations you should read up on. You also need to be careful you don't inadvertently try to use both. Pick one or the other.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 28-06-2005 at 09:02.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Printf Oddity : Programming Challange DarkAlex Programming 7 21-03-2005 08:12
Help with error please ? could not find definition of symbol 'Serial_Char_Callback' gemccnp Programming 1 19-02-2005 21:28
Printf symbol undefined? Help schenkin Programming 3 08-02-2005 16:14
Default Code and printf WilsonDJ00 Programming 2 22-01-2005 16:39
Anyone with a replacement Printf? Larry Barello Programming 5 19-03-2004 02:20


All times are GMT -5. The time now is 00:17.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi