Hi, I'm trying to use the i2c "master_slave_loopback.c" example from the Stellarisware7248 directory for the LM3S1968 and have went through the getting started excercises and other example programs and have painstakingly made sure all Linker settings etc.. etc are as described both in the Keil getting started appnote and the other LM3S1968 examples.
The list of headers as they appear are:
#include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_i2c.h" #include "driverlib/i2c.h" #include "driverlib/sysctl.h" #include "driverlib/gpio.h" #include "utils/uartstdio.h"
All those headers show up in the project under the master_slave_loopback.c file
The following error keeps persisting. The symbol in question IS defined in the properly linked header file. Can I be missing something obvious?
i2c_LoopBack.axf: Error: L6218E: Undefined symbol UARTStdioInit (referred from master_slave_loopback.o)
Same as thread: http://www.keil.com/forum/18993/
and lots of other threads.
Header files contains information for the compiler.
*.axf, *.o etc are involving the linker. The linker needs object or library files when linking a project. The linker doesn't care the slightest if you tell it "there exists a function with the name UARTStdioInit". The linker wants a file that contains already compiled code for that specific function.
So either UARTStdioInit() is missing because you have forgotten to add a library or an object file to your project. Or it is a function that you are expected to write your own customized version of.
The symbol in question IS defined in the properly linked header file.
It is most certainly not, and nor should it. It is a common rule that no symbols should be defined in header files, they should only be declared. Of this follows that you don't link headers (there is nothing there to be linked !), you just include them.
However that you do have a linking problem. Do you have the source code of uartstdio.c or is it hidden in a library ?
"Or it is a function that you are expected to write your own customized version of"
OR it is a function that is provided in Source Code form - so you have to add the Source file(s) to your project...
See: c-faq.com/.../decldef.html
Again, this is standard 'C' stuff - nothing specifically to do with Keil, nor Stellaris, nor ARM
And, as already noted, http://www.keil.com/forum/18993/ is the same - and very many other threads on this forum.
Search for "declaration" and "definition"...
As already noted, it is (correctly) not defined in any header!
This is what actually appears in the header file:
extern void UARTStdioInit(unsigned long ulPort);
Note the extern keyword - the clue is in the name...
c-faq.com/.../extlibs.html
Thanks for the insight Per Westermark! You hit the nail on the head. After looking over the code and linker settings I apparently overlooked the inclusion of the file that contained the code for this function which, after inclusion, the project built without error. I can't believe as long as I looked at this code I couldn't see the obvious. Sorry for posting a duplicate issue.
Thank you Andy! That what turned out to be the problem for me : ) As it turns out you must add existing files in Keil even though they are in designated location. Thank for that comment. Cheers!
Mike Mosley said:The symbol in question IS defined (sic) in the properly linked header file
NO: it is just declared - not defined.
You also need to include the .c file which has the definition.
http://c-faq.com/decl/decldef.html
EDIT
Hmmm ... why did this 8-year-old thread suddenly pop up as if it was new??!