linker error using wchar.h functions MQX 4.1

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

linker error using wchar.h functions MQX 4.1

1,003 Views
brettnicholas
Contributor I

Hello,

I need to use the wchar_t data type for a C project (the project is for a K70FN1M0 on a custom PCB, running MQX 4.1 and developing in CW 10.5), but am unable to access the wchar/wstring library functions such as wprintf(), wmemcpy(), wcsncpy(), and others.

I have already made sure to #include <wchar.h> and <wstring.h>, and also selected the "Enable wchar_t support" option for ARM compiler settings in the project properties menu. I am able to use the wchar_t data type without any build errors, however I get  "Link Failed" and "wprintf() undefined" errors when I try to use any wchar functions.

Please help, thanks!

- Brett

0 Kudos
5 Replies

644 Views
soledad
NXP Employee
NXP Employee

Hello Brett,

This is an abstract from service request answer.

In order to add wchar support it is necessary to set the corresponding macros and they must be rebuilt. I tried setting the macros below but I got errors. Then I undo changes and rebuilt libraries as normal and tried method 2 and it worked.

_EWL_WIDE_CHAR

_EWL_WFILEIO_AVAILABLE

_EWL_OS_DISK_FILE_SUPPORT

I took fwprintf.c from its original location (C:\Freescale\CW MCU v10.6\MCU\ARM_GCC_Support\ewl\EWL_C\src\wchar) and created a copy in my project. Then in project properties (menu Project > Properties > C/C++ Build > Settings > Compiler > Preprocessor) added the macros below.

_EWL_WIDE_CHAR=1

_EWL_OS_DISK_FILE_SUPPORT=1

As there is no prototype of the function I recommend to write a prototype at the top of the file to avoid compiler confusion.

Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

644 Views
soledad
NXP Employee
NXP Employee

Hello Brett,

Please check the below thread and let me know if this helps!!

wchar.h and MQX IO incompatibility

Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

644 Views
brettnicholas
Contributor I

Hi Soledad,

Do you have any idea how I can build the EWL wchar_t libraries? I really need to get this done....I filed a support service request a week ago, but have not heard back.

0 Kudos

644 Views
soledad
NXP Employee
NXP Employee

Hello Brett,

We are working in your issue,  we will be back with an answer asap.

Regards

Sol

0 Kudos

644 Views
brettnicholas
Contributor I

Hi Soledad,

I have already read that thread, and it doesn't help. It never specifies where the __ARM_WCHAR_NO_IO macro needs to be set. I could not find it in user_config.h

0 Kudos