Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error compiling code - vtable undefined #388

Closed
Pyro-E opened this issue Jun 30, 2024 · 17 comments
Closed

Error compiling code - vtable undefined #388

Pyro-E opened this issue Jun 30, 2024 · 17 comments

Comments

@Pyro-E
Copy link

Pyro-E commented Jun 30, 2024

Hi, getting error with "undefined reference to vtable" during compiling. Please help?

HW - esp32c6

Error:

/Users/IoT/Library/Arduino15/packages/esp32/tools/esp-rv32/2302/bin/../lib/gcc/riscv32-esp-elf/12.2.0/../../../../riscv32-esp-elf/bin/ld: /private/var/folders/5w/fptbs2sd1fs1wcpbs_78bfcr0000gp/T/arduino/sketches/32815A3D67364512A0EE046AE4D8E164/sketch/main.ino.cpp.o: in function SINRICPRO_3_0_1::SinricProDeviceInterface::SinricProDeviceInterface()': .../SinricPro/src/SinricProDeviceInterface.h:9: undefined reference to vtable for SINRICPRO_3_0_1::SinricProDeviceInterface'
/Users/IoT/Library/Arduino15/packages/esp32/tools/esp-rv32/2302/bin/../lib/gcc/riscv32-esp-elf/12.2.0/../../../../riscv32-esp-elf/bin/ld: /Users/IoT/Pyro-E Dropbox/Kevin Lu/Pyro-E/PyroE codes/Arduino/libraries/SinricPro/src/SinricProDeviceInterface.h:9: undefined reference to vtable for SINRICPRO_3_0_1::SinricProDeviceInterface' /Users/IoT/Library/Arduino15/packages/esp32/tools/esp-rv32/2302/bin/../lib/gcc/riscv32-esp-elf/12.2.0/../../../../riscv32-esp-elf/bin/ld: /private/var/folders/5w/fptbs2sd1fs1wcpbs_78bfcr0000gp/T/arduino/sketches/32815A3D67364512A0EE046AE4D8E164/sketch/main.ino.cpp.o: in function SINRICPRO_3_0_1::SinricProInterface::SinricProInterface()':
.../src/SinricProInterface.h:16: undefined reference to vtable for SINRICPRO_3_0_1::SinricProInterface' /Users/IoT/Library/Arduino15/packages/esp32/tools/esp-rv32/2302/bin/../lib/gcc/riscv32-esp-elf/12.2.0/../../../../riscv32-esp-elf/bin/ld: .../src/SinricProInterface.h:16: undefined reference to vtable for SINRICPRO_3_0_1::SinricProInterface'

collect2: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

@sivar2311
Copy link
Collaborator

Please try with the latest version is 3.1.0

@Pyro-E Pyro-E changed the title Error compiling code - Error compiling code - vtable undefined Jun 30, 2024
@sivar2311
Copy link
Collaborator

Please name the Espressif32 Arduino Core Version, the board and the sketch you're trying to compile.

@sivar2311
Copy link
Collaborator

I have no issues compiling the switch example for ESP32C6 Dev Module

  • Espressif Arduino Core version 3.0.2
  • ArduinoJson version 7.0.4
  • WebSockets version 2.4.1

@Pyro-E
Copy link
Author

Pyro-E commented Jul 1, 2024

Still same error.

My code (power measure):

//board - https://wiki.seeedstudio.com/xiao_esp32c6_zigbee/
//Espressif Arduino Core version 3.0.2
//ArduinoJson version 7.1.0
//WebSockets version 2.4.1

bool powerState = false;

// struct to store measurement from powersensor
struct {
  float voltage;
  float current;
  float power;
  float apparentPower;
  float reactivePower;
  float factor;
} powerMeasure;

// this is where you read from power sensor
// in this example, random values are used
void doPowerMeasure() {
  powerMeasure.voltage = random(2200,2300) / 10.0f;
  powerMeasure.current = random(1,20) / 10.0f;
  // powerMeasure.power = myIMU.readFloatAccelZ(); // powerMeasure.voltage * powerMeasure.current;
  // powerMeasure.apparentPower = myIMU.readFloatGyroZ(); // powerMeasure.power + (random(10,20)/10.0f);
}

void sendPowerSensorData() {
  // limit data rate to SAMPLE_EVERY_SEC
  static unsigned long lastEvent = 0;
  unsigned long actualMillis = millis();
  if (actualMillis - lastEvent < (SAMPLE_EVERY_SEC * 1000)) return;
  lastEvent = actualMillis;

  doPowerMeasure();

  // send measured data
  SinricProPowerSensor &myPowerSensor = SinricPro[POWERSENSOR_ID];
  bool success = myPowerSensor.sendPowerSensorEvent(powerMeasure.voltage, powerMeasure.current, powerMeasure.power, powerMeasure.apparentPower);
  if(!success) {
    Serial.printf("Something went wrong...could not send Event to server!\r\n");
  }
}

void setupWiFi() {
  Serial.printf("\r\n[Wifi]: Connecting");
  
  #if defined(ESP8266)
    WiFi.setSleepMode(WIFI_NONE_SLEEP); 
    WiFi.setAutoReconnect(true);
  #elif defined(ESP32)
    WiFi.setSleep(false); 
    WiFi.setAutoReconnect(true);
  #endif
  
  WiFi.begin(WIFI_SSID, WIFI_PASS);

  while (WiFi.status() != WL_CONNECTED) {
    Serial.printf(".");
    delay(250);
  }
  IPAddress localIP = WiFi.localIP();
  Serial.printf("connected!\r\n[WiFi]: IP-Address is %s\r\n", WiFi.localIP().toString().c_str());
}

void setupSinricPro() {
  SinricProPowerSensor &myPowerSensor = SinricPro[POWERSENSOR_ID];

  // setup SinricPro
  //SinricPro.restoreDeviceStates(true); // Uncomment to restore the last known state from the server.
  SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); 
  SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); });
  SinricPro.begin(APP_KEY, APP_SECRET);
}

// main setup function
void setup() {
  Serial.begin(BAUD_RATE);
  setupWiFi();
  setupSinricPro();
}

void loop() {
  SinricPro.handle();
  sendPowerSensorData();
}

@sivar2311
Copy link
Collaborator

After adding a few missing lines to your sketch above

#include <WiFi.h>
#include <SinricPro.h>
#include <SinricProPowerSensor.h>

const char* WIFI_SSID = "";
const char* WIFI_PASS = "";
const char* APP_KEY = "";
const char* APP_SECRET = "";
const char* POWERSENSOR_ID = "";
const int BAUD_RATE = 115200;
const int SAMPLE_EVERY_SEC = 60;

The sketch compiles fine:

Sketch uses 1091744 bytes (83%) of program storage space. Maximum is 1310720 bytes.
Global variables use 41360 bytes (12%) of dynamic memory, leaving 286320 bytes for local variables. Maximum is 327680 bytes.

image

@Pyro-E
Copy link
Author

Pyro-E commented Jul 2, 2024

Yes, I have those header lines. I used a new computer, reinstalled board/library, still getting this:

/Users/IoT/Library/Arduino15/packages/esp32/tools/esp-rv32/2302/bin/../lib/gcc/riscv32-esp-elf/12.2.0/../../../../riscv32-esp-elf/bin/ld: /private/var/folders/5w/fptbs2sd1fs1wcpbs_78bfcr0000gp/T/arduino/sketches/1CA1E89C3A493BAF4696B37BD3D9326E/sketch/PowerSensor.ino.cpp.o: in function `SINRICPRO_3_1_0::SinricProDeviceInterface::SinricProDeviceInterface()':

SinricProDeviceInterface.h:9: undefined reference to `vtable for SINRICPRO_3_1_0::SinricProDeviceInterface'

SinricProDeviceInterface.h:9: undefined reference to `vtable for SINRICPRO_3_1_0::SinricProDeviceInterface'

/Users/IoT/Library/Arduino15/packages/esp32/tools/esp-rv32/2302/bin/../lib/gcc/riscv32-esp-elf/12.2.0/../../../../riscv32-esp-elf/bin/ld:
/private/var/folders/5w/fptbs2sd1fs1wcpbs_78bfcr0000gp/T/arduino/sketches/1CA1E89C3A493BAF4696B37BD3D9326E/sketch/PowerSensor.ino.cpp.o: in function `SINRICPRO_3_1_0::SinricProInterface::SinricProInterface()':

SinricProInterface.h:16: undefined reference to vtable for SINRICPRO_3_1_0::SinricProInterface' SinricProInterface.h:16: undefined reference to vtable for SINRICPRO_3_1_0::SinricProInterface'

collect2: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

@kakopappa
Copy link
Contributor

kakopappa commented Jul 2, 2024

Hi,

  1. Are you using Ubuntu or Mac?

  2. Arduino IDE version

I will try on my local setup and try to replicate

@Pyro-E
Copy link
Author

Pyro-E commented Jul 2, 2024

Hi,

Mac
Arduino IDE 2.3.2

Tried 3 built-in examples with the same error.

@kakopappa
Copy link
Contributor

kakopappa commented Jul 2, 2024

image

Arduino IDE: 2.3.2
ESP32 Core: 3.0.2
MacMini: M1 - 13.6
SinricPro: 3.0.1

can compile the switch sketch with ESP32C6

@sivar2311
Copy link
Collaborator

Does a simple "Hello World" compile?

#include <Arduino.h>

void setup() {
  Serial.begin(115200);
  Serial.println("Hello World");
}

void loop{}

@Pyro-E
Copy link
Author

Pyro-E commented Jul 2, 2024

Come on, Sivar :)

Ok it's uploading on a different mac user... No idea why. I'm online :)

@sivar2311
Copy link
Collaborator

You never know ... ;)

What I wanted to say: Does this error also occur with other sketches?

But it is strange that it works with another user.

@Pyro-E Pyro-E closed this as completed Jul 3, 2024
@totalretribution
Copy link

totalretribution commented Aug 3, 2024

I also get this error if I add build_type = debug ti my platformio.ini file for using platformio inspect.

c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio/build/esp32_v3/src/main.ino.cpp.o:(.literal._ZN15SINRICPRO_3_2_015SinricProDeviceC2ERK6StringS3_+0x0): undefined reference to vtable for SINRICPRO_3_2_0::SinricProDeviceInterface'

c:/users/user/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio/build/esp32_v3/src/main.ino.cpp.o:(.literal._ZN15SINRICPRO_3_2_014SinricProClassC5Ev[_ZN15SINRICPRO_3_2_014SinricProClassC5Ev]+0x0): undefined reference to vtable for SINRICPRO_3_2_0::SinricProInterface

Im using the following in my playformio file

platform = [email protected]
platform_packages=
  framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.3
  framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.3/esp32-arduino-libs-3.0.3.zip

@sivar2311
Copy link
Collaborator

Please try if this also happens without the Arduino 3.0.3 packages (espressif32 @ 6.8.1 is Arduino Core 2.0.17)
Also please share the full platformio.ini and a minimal project to reproduce the error.

@Camm404
Copy link

Camm404 commented Nov 2, 2024

I fixed this by downgrading the ESP32 in boards manager down to 2.0.13

@kakopappa kakopappa pinned this issue Nov 3, 2024
@Akashxohani
Copy link

i also face same issue please help me

@kakopappa
Copy link
Contributor

kakopappa commented Nov 6, 2024 via email

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

No branches or pull requests

6 participants