Undefined reference to standard library functions

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

I'm getting an "undefined reference" compilation error when trying to use C standard library functions such as malloc, calloc, free, strcmp, and qsort.  How do I link-in the C standard library to provide these functions?

Thanks.

0 Likes
1 Solution

The 2073x SoCs do not support heap allocation (heaps are not very efficient in these chips). There are memory pools for dynamic allocation instead. See cfa.h, cfa_mm_Alloc(), cfa_mm_Free() and cfa_mm_Sbrk() [do not attempt to free memory allocated by cfa_mm_Sbrk()]. There is no calloc(), just use memset() to clear memory allocated by cfa_mm_Alloc.

Some std library functions are already in the ROM and you can use them. For the ones that are not there, you have to implement your own (pulling it in from the std library will waste a lot of RAM).

View solution in original post

0 Likes
2 Replies
MichaelF_56
Moderator
Moderator
Moderator
250 sign-ins 25 comments on blog 10 comments on blog

I think you will find this thread (and others on the subject) useful: Is the standard C library supported ?

0 Likes

The 2073x SoCs do not support heap allocation (heaps are not very efficient in these chips). There are memory pools for dynamic allocation instead. See cfa.h, cfa_mm_Alloc(), cfa_mm_Free() and cfa_mm_Sbrk() [do not attempt to free memory allocated by cfa_mm_Sbrk()]. There is no calloc(), just use memset() to clear memory allocated by cfa_mm_Alloc.

Some std library functions are already in the ROM and you can use them. For the ones that are not there, you have to implement your own (pulling it in from the std library will waste a lot of RAM).

0 Likes