Samuel
Member
My goal is to write all my Teensy projects in plain C, no Arduino sketches or the like. Sadly, this is incredibly hard, and I'm running into problems every step of the way. Currently, I have an incredibly minimal source file, morse.c, which just looks like this:
(Incidentally, I can't find where either things like PORTD or things like PIN_D6 are... it'd be nice if someone could point me in the right direction.)
The way I'm trying to building this is using SCons (mostly because make has no reasonable way to work on Windows), and I'm doing it by compiling everything in [arduino]\hardware\teensy\avr\cores\teensy3 (except main.cpp) to object files, and then linking them together with GCC. All of this compiling and linking is done with the options in the example Makefile, including -Wl,--gc-sections.
There have been loads of errors I've had to step around, but I've managed most of them. Now, however, I've run into a wall. Running this command:
This error occurs:
To me, the things that stick out in this error is the "undefined reference to `_kill'" and "undefined reference to `_getpid'".
Looking around on the internet, other people have suggested switching "--specs=nano.specs" for "--specs=nosys.specs". Doing that, however, I still get this error:
These "undefined reference to `vtable for blah blah blah" errors also occur using nano.specs, it seems.
How do I fix this? I just... want to compile anything at all, hahah. I'm not trying to do anything weird; just using the vanilla Teensy 3 core that ships with Teensyduino, so I'm assuming this isn't something that always happens with the core (since, you know, shipping a broken core would be weird).
In addition, I am definitely open to suggestions for better ways to work without Arduino sketches and the Arduino IDE. Perhaps there's a better way than compiling the entire core (that doesn't involve having to hand-pick .c files from the core).
Code:
#include <core_pins.h>
int main()
{
digitalWrite(11, 1);
return 0;
}
(Incidentally, I can't find where either things like PORTD or things like PIN_D6 are... it'd be nice if someone could point me in the right direction.)
The way I'm trying to building this is using SCons (mostly because make has no reasonable way to work on Windows), and I'm doing it by compiling everything in [arduino]\hardware\teensy\avr\cores\teensy3 (except main.cpp) to object files, and then linking them together with GCC. All of this compiling and linking is done with the options in the example Makefile, including -Wl,--gc-sections.
There have been loads of errors I've had to step around, but I've managed most of them. Now, however, I've run into a wall. Running this command:
Code:
arm-none-eabi-gcc -o morse.elf -Os -Wl,--gc-sections,--defsym=__rtc_localtime=0 --specs=nano.specs -mcpu=cortex-m4 -mthumb -T"C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3\mk20dx256.ld" objects\analog.o objects\eeprom.o objects\keylayouts.o objects\math_helper.o objects\mk20dx128.o objects\nonstd.o objects\pins_teensy.o objects\ser_print.o objects\serial1.o objects\serial2.o objects\serial3.o objects\touch.o objects\usb_desc.o objects\usb_dev.o objects\usb_joystick.o objects\usb_keyboard.o objects\usb_mem.o objects\usb_midi.o objects\usb_mouse.o objects\usb_rawhid.o objects\usb_seremu.o objects\usb_serial.o objects\AudioStream.o objects\DMAChannel.o objects\HardwareSerial1.o objects\HardwareSerial2.o objects\HardwareSerial3.o objects\IPAddress.o objects\IntervalTimer.o objects\Print.o objects\Stream.o objects\Tone.o objects\WMath.o objects\WString.o objects\avr_emulation.o objects\new.o objects\usb_flightsim.o objects\usb_inst.o objects\yield.o morse.o
This error occurs:
Code:
c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: section .ARM.extab.text._ZN14HardwareSerial5writeEm loaded at [0000a134,0000a13f] overlaps section .data loaded at [0000a134,0000a283]
objects\HardwareSerial1.o:(.rodata._ZTI6Stream[_ZTI6Stream]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
objects\HardwareSerial1.o:(.rodata._ZTI14HardwareSerial[_ZTI14HardwareSerial]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
objects\HardwareSerial2.o:(.rodata._ZTI15HardwareSerial2[_ZTI15HardwareSerial2]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
objects\HardwareSerial3.o:(.rodata._ZTI15HardwareSerial3[_ZTI15HardwareSerial3]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
objects\IPAddress.o:(.rodata._ZTI9Printable[_ZTI9Printable]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
objects\IPAddress.o:(.rodata+0x18): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
objects\Print.o:(.rodata+0xc): undefined reference to `vtable for __cxxabiv1::__class_type_info'
objects\usb_inst.o:(.rodata._ZTI16usb_serial_class[_ZTI16usb_serial_class]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m\libc_s.a(lib_a-signalr.o): In function `_kill_r':
signalr.c:(.text._kill_r+0xe): undefined reference to `_kill'
c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m\libc_s.a(lib_a-signalr.o): In function `_getpid_r':
signalr.c:(.text._getpid_r+0x0): undefined reference to `_getpid'
To me, the things that stick out in this error is the "undefined reference to `_kill'" and "undefined reference to `_getpid'".
Looking around on the internet, other people have suggested switching "--specs=nano.specs" for "--specs=nosys.specs". Doing that, however, I still get this error:
Code:
objects\HardwareSerial1.o:(.rodata._ZTI6Stream[_ZTI6Stream]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
objects\HardwareSerial1.o:(.rodata._ZTI14HardwareSerial[_ZTI14HardwareSerial]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
objects\HardwareSerial2.o:(.rodata._ZTI15HardwareSerial2[_ZTI15HardwareSerial2]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
objects\HardwareSerial3.o:(.rodata._ZTI15HardwareSerial3[_ZTI15HardwareSerial3]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
objects\IPAddress.o:(.rodata._ZTI9Printable[_ZTI9Printable]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
objects\IPAddress.o:(.rodata+0x18): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
objects\Print.o:(.rodata+0xc): undefined reference to `vtable for __cxxabiv1::__class_type_info'
objects\usb_inst.o:(.rodata._ZTI16usb_serial_class[_ZTI16usb_serial_class]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
These "undefined reference to `vtable for blah blah blah" errors also occur using nano.specs, it seems.
How do I fix this? I just... want to compile anything at all, hahah. I'm not trying to do anything weird; just using the vanilla Teensy 3 core that ships with Teensyduino, so I'm assuming this isn't something that always happens with the core (since, you know, shipping a broken core would be weird).
In addition, I am definitely open to suggestions for better ways to work without Arduino sketches and the Arduino IDE. Perhaps there's a better way than compiling the entire core (that doesn't involve having to hand-pick .c files from the core).
Last edited: