Error when building project with sprintf

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

Error when building project with sprintf

Jump to solution
1,624 Views
flamehaze
Contributor I

Hello,

(Sorry if my english sucks, I hope you'll understand)

So i'm in internship and i'm working on a project. So I got a problem when I build the project. Everything is fine, I don't have any errors on the code but I got this at the end : make: ***[Test_UART_v1.axf] Error 1. So I know that the problem is from the sprintf because when I delete it, everything works.

I'll just put the part with the sprintf  :

#include stdio.h

[...]

int voltage = ADC_Read(); //function created by myself

char volt_final[10];

sprintf(vol_final,"%d",voltage);

[...]

So I read some articles about the librairies and I'm new to LPCXpresso so maybe I need to do something ?

I tried itoa but it doesnt seems to work, I don't get a good result ,maybe I did something wrong with my ADC_Read().

Thank you for your help :smileyhappy:

0 Kudos
1 Solution
803 Views
lpcxpresso_supp
NXP Employee
NXP Employee

To use sprintf, you need to make sure that you are building against the "Nohost" or "Semihost" variants of the C library. For more information see:

What are none, nohost and semihost libraries? 

Switching the selected C library 

Linker error "Undefined reference to 'xxx' " 

If you need more assistance, please post full details of the error message(s) that you get in the build log:

https://community.nxp.com/message/630853 

Regards,

LPCXpresso Support

View solution in original post

2 Replies
804 Views
lpcxpresso_supp
NXP Employee
NXP Employee

To use sprintf, you need to make sure that you are building against the "Nohost" or "Semihost" variants of the C library. For more information see:

What are none, nohost and semihost libraries? 

Switching the selected C library 

Linker error "Undefined reference to 'xxx' " 

If you need more assistance, please post full details of the error message(s) that you get in the build log:

https://community.nxp.com/message/630853 

Regards,

LPCXpresso Support

803 Views
flamehaze
Contributor I

Perfect, thank you very much ! The 2 articles were usefull and I understand now :smileyhappy:. 

0 Kudos