using strncmp() vsprintf() atoi() memset() __printf_float __printf_llong in my code is creating linking issues .

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

cross mob
WadeHsiung
Level 2
Level 2
10 sign-ins 10 replies posted 5 sign-ins

Hello,

I am using Tasking IDE to develop TC397, when I using strncmp() vsprintf() atoi() memset() __printf_float __printf_llong in my code, there are some errors as below. I already include stdio.h, string.h and stdlib.h. Please help to check this problem and let me know to solve it. Thanks a lot.

ltc E106: unresolved external: strncmp - (console_menu.o)
ltc E106: unresolved external: vsprintf - (uartstdio.o)
ltc E106: unresolved external: atoi - (console_menu.o)
ltc E106: unresolved external: memset - (task_console.o)
ltc E106: unresolved external: strcmp - (cmdline.o)
ltc E106: unresolved external: __printf_float - (uartstdio.o)
ltc E106: unresolved external: __printf_llong - (uartstdio.o)
ltc F019: unrecoverable error: fatal link error
amk E452: ["makefile" 74/0] target 'foxconn.elf' returned exit code 1
amk E451: make stopped

Wade

0 Likes
1 Solution

No- What I meant is that you need to review the MCAL sources to answer the question about where the startup code symbols are defined. Because if the startup code files are not replaced by MCAL sources, the default versions will be pulled from the Standard C library and they refer to the symbols which are not defined in your custom LSL file which is included in the MCAL delivery. 

You mentioned that the unresolved externals problems did show up after you added  strncmp() vsprintf() atoi() memset() __printf_float __printf_llong to your code. Those are Standard C library functions and require the linkage of the Standard C library if those functions are not replaced by customized versions. So there should be a map file of a successfull link stage when those functions were not added to the project. Maybe you can review this map file to figure our if the references to the startup code symbols for the cores 1-5 are included in that map file too and then there must be an object file included wherein those labels are resolved. Because otherwise you get an unresolved externals error.

View solution in original post

0 Likes
18 Replies
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @WadeHsiung ,

Had this project ever been compiled successfully? And what has changed recently prior to these errors arising?

BR,

Jeremy

0 Likes

Hi Jeremy,

Thanks for your prompt reply.

This project can compiled successfully before I add strncmp() vsprintf() atoi() memset(). I guess that I miss some setting for including stdio.h, string.h and stdlib.h in IDE. But I don't know what should I do.

Wade

 

0 Likes
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @WadeHsiung ,

Please check these head files definitely contain the declaration of the above functions, it may be different from the standard C library.

BR,

Jeremy

0 Likes

Hi @Jeremy_Z ,

Yes,  the above functions all contain the declaration in head files.  

strncmp(), memset() and strcmp() are in the sting.h.

vsprintf() is in the stdio.h.

atoi() is in the stdlib.h.

WadeHsiung_0-1678668731372.png

WadeHsiung_1-1678668804974.png

WadeHsiung_2-1678668832255.png

 

Wade

 

 

 

 

 

0 Likes
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @User13836
Can you share some advice about the question?
BR,
Jeremy

0 Likes

Hi @Jeremy_Z  @User13836,

I am still waiting for your response, please help to check my problem and feedback to us. Thanks a lot.

Wade

0 Likes
Jeremy_Z
Moderator
Moderator
Moderator
1000 replies posted 250 sign-ins 100 likes received

Hi @WadeHsiung ,
Sorry for replying late.
Can you upload a simple code that can replicate the above compile error?
BR,
Jeremy

0 Likes

Hi @Jeremy_Zhou,

Actullay, we are using davinci configurator to gen code on Tasking IDE, is there any doubts about the setting of davinci configurato?

Wade

0 Likes

Hi @Jeremy_Zhou,

How could I add C standard library in Tasking IDE?

WadeHsiung_0-1678861254817.png

 

0 Likes

The unresolved symbols are defined in the Standard C library. If you want to include the Standard C library you can enable the checkbox:

Link default libraries

in the Linker >> Libraries menu of the TASKING Eclipse environment.

Best regards,

Ulrich Kloidt
TASKING tools support

 

0 Likes

Hi  @User13836,

Thnaks for your reply. I already tried to select Link default libraries, but there are another errors as below pictures. Please help to check it and give us some suggestions. Thank you.

WadeHsiung_0-1678867537945.png

Wade

 

 

0 Likes

The error messages are caused by the missing definitions of those symbols in the linker LSL file used. It seems all related to the startup code of cores 1 to 5. So for core 0 the labels are resolved. Which C startup code does your application use? The default cstart.c which is by default added to a new created eclipse project? Or do you use a 3rd party C staretup code instead? Is the application a multi core application or does it use only core 0? If only core 0 is used and you are using the default startup code you can uncheck the options to start the other cores in menu:

C/C++ Build >> Startup Configuration

Then the default startup code for the other cores which refers to the unresolved linker labels is not linked anymore and the errors might disappear.

0 Likes

Hi  @User13836,

Our statup code is provided by autosar, I thinkg that's why we don't select "Link default libraries" in our project before. Could we add C standard library only by manual instead of  selecting "Link default libraries"? If yes, please let me know how to do in the Tasking IDE or do you have any other suggestions? Thanks a lot.

Wade

0 Likes

Default versions of the C startup code for all cores are included in the Standard C library. Thus adding this library to the link stage will also include the startup code for the other cores if there are references to the startup code symbols in your application code. You can have a look if the autosar startup code refers to the symbols

_start_tc1, _start_tc2, ..., _start_tc5

Maybe you can share the content of the map file. The complete map file content is not required. It is sufficient to share the options used which are listed at the beginning of the map file. The map file is also generated when a linker error occurs.

I would like to know the order of the libraries. The linker is processing the libraries from left to right. First come first serve. If the same global symbol is defined in multiple libraries, the object module included in the first lib which includes the definition of the symbol will be used. The other object modules included in the following libs which do also include a definition of the same symbol will be ignored. 

0 Likes

Hi  @User13836,

Please see attached map file for you ref. Thanks.

Wade

0 Likes

Thanks for sharing the map file. This is the version without adding a Standard C library.

The map file shows that the startup code labels for core 1 to 5 are referred to in module Os_Hal_Core_Lcfg.o:

* Undefined symbols
====================
+-----------------------------------------------------------------------------------+
| Symbol | Referenced in |
|===================================================================================|
...
| _start_tc1 | Os_Hal_Core_Lcfg.o |
| _start_tc2 | Os_Hal_Core_Lcfg.o |
| _start_tc3 | Os_Hal_Core_Lcfg.o |
| _start_tc4 | Os_Hal_Core_Lcfg.o |
| _start_tc5 | Os_Hal_Core_Lcfg.o |

 

Maybe you need to review the MCAL libs since those labels must be defined in an object file part of the MCAL files because otherwise the default startup code will be pulled from the Standard C library to resolve the symbols.

0 Likes

Hi  @User13836,

Do you mean that we should add the libs in MCAL or DAVINCI CONFIGURATOR not in TASKING IDE?

Wade

0 Likes

No- What I meant is that you need to review the MCAL sources to answer the question about where the startup code symbols are defined. Because if the startup code files are not replaced by MCAL sources, the default versions will be pulled from the Standard C library and they refer to the symbols which are not defined in your custom LSL file which is included in the MCAL delivery. 

You mentioned that the unresolved externals problems did show up after you added  strncmp() vsprintf() atoi() memset() __printf_float __printf_llong to your code. Those are Standard C library functions and require the linkage of the Standard C library if those functions are not replaced by customized versions. So there should be a map file of a successfull link stage when those functions were not added to the project. Maybe you can review this map file to figure our if the references to the startup code symbols for the cores 1-5 are included in that map file too and then there must be an object file included wherein those labels are resolved. Because otherwise you get an unresolved externals error.

0 Likes