Delete asstring results in compiler error "undefined reference to sbrk"

I want to prepare a AS4.12 project for AS6 migration and have deleted therefore the asstring library.

The program source code is C and normaly all used functions fo the asstring should be supported by the #include <string.h>.

But when I compile I get only 6 errors:

“undefined reference to sbrk” without any additional information.

I found no information about this error at the help.

Hello Klaus,

this error occurs when you are using a function like sprintf() and others, that use dynamic memory / arguments.
Until AS6 the shipped libc was not complete in that regard and not all functions were supported.
You can see the limitation here: B&R Online Help

But since you are preparing for AS6, I recommend opening the project there and profit from the fact that the libc is now (more) complete: B&R Online Help
→ Just pay attention to the section Dynamic memory management (heap)

Edit: Also let me introduce you to the migration tool that will help you converting everything and reduces your workload for that conversion: here

1 Like

Hi @KWIE , is it answer from Michael enough for you or is there still some open question?

Hallo Michael, Hello Jaroslav,

first at all, sorry for my late response.

Your information helped me to find the right way - thank you very much for this.

At the project (95% C-Code) I searched for all used functions of AsString or string.h and replaced in AS4.12 all used convertion functions between ascii and values

like (ftoa, atof, itoa, atoi) with the correspondending functions of the AsBrStr Lib.

Now I got no errors in AS4.12 but after Migration in AS6.5 I got >200 errors (nearly all have someting to do with C-Code).

Now I am struggeling to find all reasons for these errors.

E.g. : Fehler expected ‘)’ before ‘(’ token Ze: 43, Sp: 20 C:\Z\Projekte_AS60\PLC_TF3_5_950b_20251203_TST\Logical\Libraries\Logger\Logger.c
at the following code line 43

1 Like

thanks for update. I marked your summary as a solution for AS4.12

Hello Klaus,

regarding a few of those you said you converted to AsBrStr: I would recommend trying to stick to C functions where possible - both AsString and AsBrStr are mainly to provide such functionality to the other languages that don’t have them already. itoa and atoi for example exist in stdlib.h, which you have access to in C :slight_smile:

Your problem regarding the EXFUN - this is documented here: B&R Online Help in the header Declarations via macro _EXFUN, such as int _EXFUN(rand, (_VOID)), now cause an error message..
Generally speaking I would just remove it and do #include <stdlib.h> which provides you with abs() as well as itoa, ftoa, …

Also please don’t let me wait another week for a reply :wink: (although I won’t be available until january after today)

1 Like

Thank you one more time again.

I changed the _EXFUN dependent to the help and this errors are now eliminated.

At the end I have a project without errors but it was tricky to found all error sources because there was somtimes >400 error messages and the trigger was not one of the fist messages.

My last problem at the moment is, that I have replaces in AS4.12 an AverageFilter from the discarded lib LoopCont with the block from the MTFilter lib.

But in AS6 I didn’t find the MTFilter Lib and I found also no information, that it is not supported in AS6.

Hello Klaus,

the MTFilter Lib is part of the mappControl Technology Package. It is not installed by default but you can download it using the “Upgrades” function.

1 Like

Ok, now also this point is solved.

I wish all participants a Merry Christmas and a healthy and happy New Year, and thank you once again for all your help.

3 Likes