Hi, I've read some good posts here about linking errors, but not one of them seem to cover my situation:
I've written a custom ASM assembly language routine for my C6727 C++ program.
In my Magic.ASM file, I have:
.global _my_ti_asm_magic_func
_my_ti_asm_magic_func:
<INSTRUCTIONS THAT MAKE MAGIC>
B B3 ; Return control to caller
In my Program.c file, I have:
extern my_ti_asm_magic_func(type arg1, type arg2, ...);
//..snip
//Let's call the magic func:
my_ti_asm_magic_func(type arg1, type arg2, ...);
I add the .asm file to my project, and recompile.
Upon inspecting the .map file, it shows me that the symbol _my_ti_asm_magic_func correctly has an address:
10018b80 _my_ti_asm_magic_func
BUT, there is also a weird-looking symbol that resembles my own symbol. I presume this is the C equivalent of the symbol, due to the "extern" declaration I placed in the C code, and it got name-decorated by the compiler in this weird way. This symbol shows up as UNDEFINED:
UNDEFED _Z21_my_ti_asm_magic_funcPfS_S_ii
This obviiously causes a linking error:
undefined first referenced symbol in file --------- ---------------- my_ti_asm_magic_func(float *, float *, float *, int, int) C:/code/Program.objerror: unresolved symbols remainerror: errors encountered during linking;
I've read:
Section 3.6.2 in SPRU187B that describes mixing C and assembly to no avail.
Also SPRA806, hoping that even though it seems old, might give me some clues as to the correct usage of this feature of calling ASM from C. I've followed those steps to no avail.
Can you help me? How do i resolve this?
Dave5396 I've written a custom ASM assembly language routine for my C6727 C++ program ...
Dave5396BUT, there is also a weird-looking symbol that resembles my own symbol. I presume this is the C equivalent of the symbol, due to the "extern" declaration I placed in the C code
So is it C, or is it C++ ?
Google "C++ name mangling"...
Right, it's C++, so using:
#ifdef __cplusplus extern "C" { #endif /* ... */ #ifdef __cplusplus } #endif
fixes the linking error.
Thanks !
More detail on name mangling can be found in this wiki article. -George
TI C/C++ Compiler Forum ModeratorPlease click Verify Answer on the best reply to your question.The Compiler Wiki answers most common questions.Track an issue with SDOWP. Enter your bug id in the "Find Record ID" box.