arduino icon indicating copy to clipboard operation
arduino copied to clipboard

undefined reference to operator delete

Open uXeBoy opened this issue 5 years ago • 6 comments

Getting this error during compilation - seems to be related to missing libstdc++

...is there a possible solution??

uXeBoy avatar Nov 25 '19 12:11 uXeBoy

I'm getting on some projects similar "delete" missing c++ issue I think I workarounded this somehow but I would like if "gornjas" or somebody would propose a better solution to this...

On 11/25/19, uXeBoy [email protected] wrote:

Getting this error during compilation - seems to be related to missing libstdc++

...is there a possible solution??

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/f32c/arduino/issues/33

emard avatar Nov 26 '19 07:11 emard

If you have problems with operator delete, you should also have problems with operator new. Both are implemented in hardware/fpga/f32c/cores/f32c/new.cpp.

A simple, minimal example which can reliably provoke the error could help us pinpoint the exact problem.

gornjas avatar Nov 26 '19 10:11 gornjas

I think I see the problem now... 🤦

That new.cpp does not include C++14 style 'sized deallocation' functions:

https://en.cppreference.com/w/cpp/memory/new/operator_delete

uXeBoy avatar Nov 26 '19 11:11 uXeBoy

Hmm as a person who uses or cares about C++ only when shotgun-forced, I can only comment that our new.cpp was blindly cloned many years ago from (I believe): https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/new.cpp

Does your application compile with AVR arduino?

[edit]: oh, I see, we should just add delete variants which ignore the extra argument. Could you try replacing our new.cpp with the one from https://github.com/stm32duino/Arduino_Core_STM32/blob/master/cores/arduino/new.cpp

and report whether this helps?

gornjas avatar Nov 26 '19 11:11 gornjas

Did some research, and I ended up just adding -fno-sized-deallocation to the c++ compiler flags in platform.txt and that fixed it... maybe a better solution if the the added delete variants would just be dummies anyway?

uXeBoy avatar Nov 26 '19 11:11 uXeBoy

I like your approach with patching compiler flags in platform.txt better, as there's no point in introducing more dummy functions which are equivalent to the existing ones, and just occupy space.

I'd leave it to Davor to check whether adding the proposed flag in platform.txt does any harm, as he's using fpgarduino much more frequently than I am, and if it doesn't break anything to proceed and commit the change.

gornjas avatar Nov 26 '19 12:11 gornjas