Re: Link Error: L1822: Symbols are undefined

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Link Error: L1822: Symbols are undefined

3,080 Views
mauricio2346
Contributor II
HI:

for these days i´m trying to migrate my whole work on microcontrolers (proyects) from Metrowerks CW 3.0 to Freescale CW 6.2 with some problems.

for example, with some libraries that doesn't link to their declarations on the main program.   when compile the proyect some errors and warnings appear:

Link Error  : L1822: Symbol Delayms_FUi in file C:// .....  ..... is undefined

also with other "symbols".  

the code from .h file where Delayms is declared:

#include "derivative.h" /* include peripheral declarations */

#ifndef __TIMERAPI_H
#define __TIMERAPI_H    1
void Delayus(unsigned int us);
void Delayms(unsigned int ms);
#endif /* __TIMERAPI_H */

the code on the header of the main program:

#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include "TIMERAPI.h" /*include Delays declarations*/
#include "STEPPERAPI.h"


plus, errors seems to apear on .O files from proyect_data\ObjectCode\main.ccp.o
those errors didn't appear in my old version of CW from Metrowerks.

What can i do ?

Regards;

Mauricio
Labels (1)
0 Kudos
2 Replies

308 Views
CrasyCat
Specialist III
Hello
 
The issue here is that you are calling a function implemented in an ANSI C module from a C++ module.
If this is really what you want to do you need to tell the compiler you are doing that.
 
This is done enclosing function prototypes from your ANSI C module between
#ifdef __cplusplus
extern "C" {
#endif
 
...

#ifdef __cplusplus
}
#endif
 
So your module TIMERAPI.h should look as follows:
#ifdef __cplusplus
extern "C" {
#endif
 
void Delayus(unsigned int us);
void Delayms(unsigned int ms);

#ifdef __cplusplus
}
#endif
 
Note that V3.0 was behaving exactly in the same way. I assume in V3.0 you were building a file called main.c or you did use an option to force compilation of .cpp file as ANSI C source files.
 
CrasyCat
0 Kudos

308 Views
mauricio2346
Contributor II
Hi
Thanks, maybe i should continue creating C based proyect instead of C++, so your solution seems to be very interesting

using C support instead C++, my module did't present that linking problem, but i had to change some of the prototype's definitions, defining my functions as extern functions.

in this moment i'm working well!!!


0 Kudos