Getting a linker error while building a project using arm-none-eabi-g++

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

Getting a linker error while building a project using arm-none-eabi-g++

549 Views
sushmasan
Contributor II

Hello Team,

I am seeing a linker error while building the code using C++ compiler "arm-none-eabi-g++"

Let me add little details, I have an existing project which has only C source files, but now I have created a new source file which is C++ based. Previously I used to build the code using "arm-none-eabi-gcc" C compiler, but after adding the new source file I have changed the compiler option to "arm-none-eabi-g++".

Surprisingly I am seeing many linker errors, adding one example error message here,

undefined reference to `sprintf(char*, char const*, ...)'

Even though sprintf was used in many source files, but this error shown in few source files.

I was able to build the code (before adding C++ source file) using "arm-none-eabi-gcc" option, but the error was seen only while building the code using "arm-none-eabi-g++" compiler command.

Can someone please let me know, what is going on here?

Regards,
San

0 Kudos
Reply
3 Replies

471 Views
sushmasan
Contributor II

Hello @Alice_Yang,

Few observations.

The existing project is created as a C project, but now I have added a .cpp source file to that project.

The existing project uses gcc compiler for building the code, where as after adding new .cpp file, I changed the compiler to g++ for building the code. That's when I saw the issue.

Please let me know, based on the above inputs, can you able to provide any pointers?

I am sorry, I can't share the project as it contains the confidential source code.

Regards,
San

 

0 Kudos
Reply

424 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @sushmasan 

Check the error message, it seems the lib you used doesn't support sprintf(char*, char const*, ...)'.  It is recommend to replace the library. Some libraries only support C. About libraries description, please refer to "19.7 Libraries and linker scripts" of <MCUXpresso_ide_User guide>. I attach it for you.

Or do not use like print.

Alice_Yang_0-1720433388510.png

 

BR

Alice

0 Kudos
Reply

520 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @sushmasan 

For better help you , please share your project. I help you check it on my side. thanks.

 

BR

Alice

0 Kudos
Reply