Link Error: L1822: Symbol MCU_init__Fv in file main.cpp.o is undefined

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Link Error: L1822: Symbol MCU_init__Fv in file main.cpp.o is undefined

3,392件の閲覧回数
JOTAEME
Contributor I
I'm getting this message when I try to compile a project, but I'm using Device Initialization, so I don't know why it can't find a symbol it's supposed to be defined automatically.
I already worked in a different project with the same version of CodeWarrior and did the same procedure to create the project, and never got that error. The only difference is that I used the MC9S08GT60A, wich I got to flash program it fine and with no problems. Now, I'm trying to flash program the MC9S08GT16 and, as I said before, it brings up this error.
Does anybody know why is this?
ラベル(1)
0 件の賞賛
返信
3 返答(返信)

1,211件の閲覧回数
CrasyCat
Specialist III
Hello
 
This is due to the C++ name mangling.
 
Device Initialization is generating ANSI C source code and you are trying to call an ANSI C function from a C++ module.
 
You have to let the compiler know that the function MCU_init is an ANSI C function.
 
Just enclose the MCU_init function prototype between
#ifdef __cplusplus
extern "C" {
#endif
 
and
 
#ifdef __cplusplus
 }
#endif
 
Example
#ifdef __cplusplus
extern "C" {
#endif
void MCU_init(void);
#ifdef __cplusplus
 }
#endif
 
I hope this helps.
 
CrasyCat
0 件の賞賛
返信

1,211件の閲覧回数
yida
Contributor I

After I used the solution, I got a "C1073: Linkage specification contradicts earlier specification" instead. And I defined it only once.

#ifndef _HARDWARE_H_
#define  _HARDWARE_H_

#ifdef __cplusplus
extern "C" {
#endif

void PLL_init();

#ifdef __cplusplus
 }
#endif
#endif

What shall I do now?

0 件の賞賛
返信

1,211件の閲覧回数
CrasyCat
Specialist III

Hello

 

First this seems to be a completely different topic.

 

Can you please post a new message for that.

 

Are you forcing compilation of whole application in C++?

Did you look at the preprocessing listing for the source file generating the message?

 

Do you have other definition/declaration for PLL_Init there?

 

CrasyCat

0 件の賞賛
返信