Problems compiling

Status
Not open for further replies.

stivo

Member
Hi. I've just started experimenting with my new teensy 3.6. While trying to use some of my existing c++ code I found I could not compile anything using c++ libraries. Even the most simple program that includes a c++ library will fail to link.

My current system:
Mac OS 10.14
Arduino 1.8.7
Teensyduino 1.44


Even this code fails to build:
Code:
[B]#include <iostream>[/B]

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Output:
Code:
/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/stivo/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/stivo/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/stivo/Documents/Arduino/libraries -fqbn=teensy:avr:teensy36:usb=serial,speed=180,opt=o2std,keys=en-us -ide-version=10807 -build-path /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950 -warnings=none -build-cache /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_cache_150652 -verbose /Users/stivo/Documents/Arduino/sketch_oct06b/sketch_oct06b.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/stivo/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/stivo/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/stivo/Documents/Arduino/libraries -fqbn=teensy:avr:teensy36:usb=serial,speed=180,opt=o2std,keys=en-us -ide-version=10807 -build-path /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950 -warnings=none -build-cache /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_cache_150652 -verbose /Users/stivo/Documents/Arduino/sketch_oct06b/sketch_oct06b.ino
Using board 'teensy36' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr
Using core 'teensy3' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr
Detecting libraries used...
/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++ -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK66FX1M0__ -DTEENSYDUINO=144 -DARDUINO=10807 -DF_CPU=180000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3 /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950/sketch/sketch_oct06b.ino.cpp -o /dev/null
Generating function prototypes...
/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++ -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK66FX1M0__ -DTEENSYDUINO=144 -DARDUINO=10807 -DF_CPU=180000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3 /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950/sketch/sketch_oct06b.ino.cpp -o /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950/preproc/ctags_target_for_gcc_minus_e.cpp
/Applications/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950/preproc/ctags_target_for_gcc_minus_e.cpp
Compiling sketch...
/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/precompile_helper /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3 /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950 /Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++ -x c++-header -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -fno-exceptions -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK66FX1M0__ -DTEENSYDUINO=144 -DARDUINO=10807 -DF_CPU=180000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3 /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950/pch/Arduino.h -o /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950/pch/Arduino.h.gch
/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++ -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -fno-exceptions -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK66FX1M0__ -DTEENSYDUINO=144 -DARDUINO=10807 -DF_CPU=180000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950/pch -I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3 /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950/sketch/sketch_oct06b.ino.cpp -o /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950/sketch/sketch_oct06b.ino.cpp.o
Compiling libraries...
Compiling core...
Using precompiled core: /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_cache_150652/core/core_b60bcd800d064b14c3a5ce60e9382b4e.a
Linking everything together...
/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/[B]arm-none-eabi-gcc[/B] -O2 -Wl,--gc-sections,--relax,--defsym=__rtc_localtime=1538866587 -T/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/mk66fx1m0.ld -lstdc++ -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -o /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950/sketch_oct06b.ino.elf /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950/sketch/sketch_oct06b.ino.cpp.o /var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950/../arduino_cache_150652/core/core_b60bcd800d064b14c3a5ce60e9382b4e.a -L/var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950 -larm_cortexM4lf_math -lm
/var/folders/wn/k2b249w574ndp_5sm22w94y00000gn/T/arduino_build_94950/sketch/sketch_oct06b.ino.cpp.o: In function `__static_initialization_and_destruction_0':
[B]/Applications/Arduino.app/Contents/Java/hardware/tools/arm/arm-none-eabi/include/c++/5.4.1/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/Applications/Arduino.app/Contents/Java/hardware/tools/arm/arm-none-eabi/include/c++/5.4.1/iostream:74: undefined reference to `std::ios_base::Init::~Init()'[/B]
collect2: error: ld returned 1 exit status
Error compiling for board Teensy 3.6.

Its using arm-none-eabi-g++ to compile but then uses arm-none-eabi-gcc to link. If I manually link it and replace arm-none-eabi-gcc with arm-none-eabi-g++ it links ok.

What am I doing wrong? Why won't it use arm-none-eabi-g++ for linking?

Sorry if this is a simple mistake and thanks in advance for your help.
 
Ok. Don't include iostream.

I had it included in all my files but I commended out all function calls to it. That's not good enough. So far things are ok when I don't include iostream. My guess is the teensy has no concept of stdin and stdout.

Sorry for the mistake.
 
Since embedded processors are mainly used to interact with machine peripherals and sensors, and since prgm space is limited, there is in fact no concept of stdin and stdout.

If you need a console, i.e. for status and debug text output, you'll have to use the Serial stream object.
 
Status
Not open for further replies.
Back
Top