cancel
Showing results for 
Search instead for 
Did you mean: 

CubeIDE and c++ routines problems

freya17365
Associate II

Hi to all,

I am moving to SPM32CubeIDE on Linux and, as a newby, I encountered a lot of problems.

I started a new empty C++ project and I put all my flies and classes.

I also included syscall.c file (renamed in syscall.cpp) as in it there are _seek(), _read(), ..... routines, but everytime I compile my program I always got:

 

(.text._close_r+0xc): warning: _close is not implemented and will always fail

(.text._lseek_r+0x10): warning: _lseek is not implemented and will always fail

(.text._read_r+0x10): warning: _read is not implemented and will always fail

(.text._write_r+0x10): warning: _write is not implemented and will always fail

Finished building target: F303.elf

 

What should I do to make the linker to attach those routines?

 

Thank you

Freya

 

4 REPLIES 4
KnarfB
Principal III

Those are linker warnings, not errors. They are harmless as long as you don't intend using a file system on the board and you can ignore them.

The messages say what you could do for fixing these warnings: implement the functions. An empty function body will do. Since you are using C++, there is a chance that these functions are already implemented, but in C++, not C. C++ does name mangling and the linker will not find the C++ implmentations unles they are decorated by extern "C".

 

as a newby,

Look for known good examples before changing too much. Embedded waters are deep and fierce creatures are living there.

hth

KnarfB

AScha.3
Chief III

Hi,

basically the IDE is on C . Just start stm32-project, as c++ , generate code from your MX/ioc .

So dont rename main.c , etc. , generated code files /HAL lib is always C ;

and

> I put all my flies and classes

-- no. Only menu -> import -> file system ... will let the IDE know, this is part of your project. So import your files.

Just from main.c call your C++ ...whatever :  my_main.cpp , then you get working project, cpp compiler is called, on your c++ files, other is and will be C.

If you feel a post has answered your question, please click "Accept as Solution".
TDK
Guru

> syscall.c file (renamed in syscall.cpp)

You generally should not be renaming C files to C++ files, especially for low-level system files like this. This mangles the function names so the linker doesn't see them for what they are anymore.

The majority of "C++" projects have a significant number of C files in them. Just an artifact of how the infrastructure grew up.

If you want to create C++ source files, create new ones and launch them from a function call within main().

If you feel a post has answered your question, please click "Accept as Solution".
freya17365
Associate II

Thank you to all,

the problem is solved. The fil continue to have extension .cpp, but I added before the function declaration extern "C" and now I have no more warnings.

 

Thank you

Freya