Skip to content

fixes build for ESP32s - #539

Closed
ian7 wants to merge 7 commits into
FastLED:masterfrom
ian7:master
Closed

ian7 wants to merge 7 commits into
FastLED:masterfrom
ian7:master

Conversation

@ian7

@ian7 ian7 commented Dec 11, 2017

Copy link
Copy Markdown

it seems that definition of __cxa_pure_virtual is already included in ESP32 build chain

@focalintent

Copy link
Copy Markdown
Contributor

@samguyer can you confirm that the esp32 build chain you’re using includes these symbols now as well?

@samguyer

Copy link
Copy Markdown
Contributor

It never seemed to be a problem in the Arduino IDE environment. I have not tested it elsewhere.

@ian7

ian7 commented Dec 12, 2017

Copy link
Copy Markdown
Author

this is correct. I guess that original Arduino IDE uses different compiler flags. When I'm trying to build with PlatofmIO, I'm getting this:

Linking .pioenvs\esp32dev\firmware.elf
.pioenvs\esp32dev\lib\libFastLED_ID126.a(FastLED.o): In function `__cxa_pure_virtual':
c:\Users\Marcin\Documents\PlatformIO\Projects\automation\dining-light/.piolibdeps\FastLED_ID126/FastLED.cpp:243: multiple definition of `__cxa_pure_virtual'
c:/users/marcin/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/lib\libstdc++.a(pure.o):pure.cc:(.text.__cxa_pure_virtual+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pioenvs\esp32dev\firmware.elf] Error 1

@focalintent

Copy link
Copy Markdown
Contributor

This change needs to be gated by whether or not building for arduino vs platformIO then (because the far majority of users are building using the arduino ide - the library biases to building cleanly in there)

@Flos

Flos commented Jan 13, 2018

Copy link
Copy Markdown

I have the same issue,
I think the bigger the project, the less happy you are with the Arduino IDE. I use Visual Studio Code with PlatformIO. It is so easy to structure your code in multiple files there, navigate between them, jump to the source code of referenced libs and using the code completion. I use now @samguyer repository since the version in PlatformIO is broken for the ESP32.

@howsTricks

Copy link
Copy Markdown

@ivankravets Wondering if you can help with this, is PlatformIO using different compiler flags than the Arduino IDE when targeting ESP32?

@ivankravets

Copy link
Copy Markdown
Contributor

How to reproduce this issue? I tried PlatformIO and Arduino IDE – the same error:

In file included from /Users/ikravets/.platformio/lib/FastLED_ID126/FastLED.h:68:0,
from /private/var/folders/nj/nt38kxwd2xxfl5l42np_w7qw0000gn/T/tmpCXgemV/src/AnalogOutput.ino:1:
/Users/ikravets/.platformio/lib/FastLED_ID126/fastspi.h:110:23: note: #pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output
#      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"
^
/private/var/folders/nj/nt38kxwd2xxfl5l42np_w7qw0000gn/T/tmpCXgemV/src/AnalogOutput.ino: In function 'void showAnalogRGB(const CRGB&)':
/private/var/folders/nj/nt38kxwd2xxfl5l42np_w7qw0000gn/T/tmpCXgemV/src/AnalogOutput.ino:29:29: error: 'analogWrite' was not declared in this scope
analogWrite(REDPIN,   rgb.r );
^
*** [.pioenvs/esp32dev/src/AnalogOutput.ino.o] Error 1

Which example should I try?

@ivankravets

Copy link
Copy Markdown
Contributor

@howsTricks we use the same flags, Espressif team officially maintains PlatformIO build script.

Which flags are missed? Below is an output from the last build:

xtensa-esp32-elf-g++ -o .pioenvs/esp32dev/FrameworkArduino/IPAddress.o -c -fno-rtti -fno-exceptions -std=gnu++11 -Wno-error=deprecated-declarations -Wno-error=unused-function -Wno-unused-parameter -Wno-sign-compare -fstack-protector -Os -g3 -nostdlib -Wpointer-arith -Wno-error=unused-but-set-variable -Wno-error=unused-variable -mlongcalls -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -DARDUINO=10805 -DARDUINO_ARCH_ESP32 "-DARDUINO_BOARD=\"Espressif ESP32 Dev Module\"" -DESP32 -DESP_PLATFORM -DF_CPU=240000000L -DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DPLATFORMIO=30502 -DARDUINO_ESP32_DEV -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/config -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/bluedroid -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/app_trace -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/app_update -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/bootloader_support -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/bt -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/driver -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp32 -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/esp_adc_cal -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/ethernet -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fatfs -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/freertos -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/heap -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/jsmn -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/log -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mdns -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mbedtls -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/mbedtls_port -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/newlib -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/nvs_flash -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/openssl -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/spi_flash -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/sdmmc -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/spiffs -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/tcpip_adapter -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/ulp -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/vfs -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wear_levelling -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/xtensa-debug-module -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/console -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/soc -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/newlib -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/coap -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/wpa_supplicant -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/expat -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/json -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/nghttp -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/lwip -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/cores/esp32 -I/Users/ikravets/.platformio/packages/framework-arduinoespressif32/variants/esp32 /Users/ikravets/.platformio/packages/framework-arduinoespressif32/cores/esp32/IPAddress.cpp

@howsTricks

Copy link
Copy Markdown

Hi @ivankravets,
Try with this code

#include <Arduino.h>
#include <FastLed.h>

#define NUM_LEDS 4
#define DATA_PIN 17

CRGB leds[NUM_LEDS];

void setup() {
    pinMode(DATA_PIN, OUTPUT);
    FastLED.addLeds<WS2811, DATA_PIN>(leds, NUM_LEDS);
}

void loop() {
        leds[2] = CRGB::Blue;
        FastLED.show();
}

This is the error you should get without the fix, relating to multiple definitions of function "__cxa_pure_virtual"

Linking .pioenvs\esp32dev\firmware.elf
.pioenvs\esp32dev\lib\libFastLED_ID126.a(FastLED.o): In function `__cxa_pure_virtual':
c:\Users\Marcin\Documents\PlatformIO\Projects\automation\dining-light/.piolibdeps\FastLED_ID126/FastLED.cpp:243: multiple definition of `__cxa_pure_virtual'
c:/users/marcin/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/lib\libstdc++.a(pure.o):pure.cc:(.text.__cxa_pure_virtual+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pioenvs\esp32dev\firmware.elf] Error 1

@ivankravets

Copy link
Copy Markdown
Contributor

Thanks, this is a bug. I fixed it in platformio/platformio-core@904c546

I've just created a PR #563 with a temporary solution for ALL PlatformIO Core versions. (See http://docs.platformio.org/en/latest/librarymanager/config.html#libarchive)

So, that PR will work in the current stable version and in the future versions.

@howsTricks

Copy link
Copy Markdown

Awesome, thanks!

@marcmerlin

Copy link
Copy Markdown
Contributor

would you mind closing/deleting this pull request then? Thanks.

@ian7 ian7 closed this Jan 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants