Skip to main content
Visitor II
August 3, 2024
Question

CubeIDE and c++ routines problems

  • August 3, 2024
  • 4 replies
  • 1197 views

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

 

    This topic has been closed for replies.

    4 replies

    Super User
    August 3, 2024

    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

    Super User
    August 3, 2024

    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.

    Super User
    August 3, 2024

    > 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().

    Visitor II
    August 3, 2024

    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