I started a new project with an LPC2106 cpu. There are two files in it: blinky.c and time.c In Blinky.c I declare: extern void init_time(void); And call it in the main function. Function is written in time.c When I link I get a undefined symbol report on init_time If I look at blinky.lst I can see a call to a external symbol called: "Z9init_timev" And if I look at time.lst I can see a global symbol "init_time" Anyone know what I am doing wrong???
Are you sure that: 1) time.c is definitely included in your project? 2) The declaration of init_time in time.c is *exactly* the same, ie void init_time(void)? Stefan
Absolutely sure! Both time.c and blinky.c shows up in the project window. Both are compiled. Still... Why the "Z9" in the beginning of init_timer....?
The complete project can be found here: http://www.fabricius.nu/blinky.zip It is only 18 kbyte //Helge
Sorry, I can't compile ARM projects. Stefan
"Absolutely sure! Both time.c and blinky.c shows up in the project window. Both are compiled." That answers Stefan's 1st question, but not his 2nd: Is the declaration of init_time in time.c is *exactly* the same, ie void init_time(void)? "Still... Why the "Z9" in the beginning of init_timer....?" It is quite possible that the compiler could add prefixes and/or suffixes related to the type of the function, its parameters, etc. That's why Stefan's 2nd question is so important! One way to guarantee that the declaration matches the definition is to put the declaration of init_time() in a header file - say time.h - and #include that it both main.c and time.c. That way, the compiler can give an error/warning if the declaration does not match the definition, since it can see both when it compiles time.c!
The declaration is the same as it is possible to see if the project is downloaded. I think I will wait for support to answeer my question. It looks like nobody else have used the ARM...
You should really have checked (your declaration is the same as the definition) before posting a message like that. They look obviously different to me.
You are correct. I did leave out the void when writing the function. Have tried som many ways.... But problem is still there, with or without the "void".
Your problem is the name of the blinky.c source file. It's actually in all upper-case: BLINKY.C. Now the Keil ARM tools are based on GNU compilers, which are Unix-born, and thus do care about the case of filenames. From GCC's point of view, "BLINKY.C" is a C++ file name, and so it compiled the source as C++. C++ puts a lot more information into a function's linker-visible name than C (google:"name mangling"), which break direct link compatibility with C. Thus your problem. Proposed solution: remove BLINKY.C from the project, rename the file to lower-case, and add it back to the project under the new name.
View all questions in Keil forum