Closed Gulpman closed 1 year ago
I tried to find out what's going on and searched for "undefined reference to vtable for" and stumbled upon this article: https://stackoverflow.com/questions/3065154/undefined-reference-to-vtable
User iammilind says:
another Qt related problem is that if the file with Q_OBJECT is copied externally, but not yet part of the .pro file, then though it compiles fine, it doesn't link. We have to add that .h/.cpp file into the .pro file to be able to qmake.
Though this is Arduino and not Qt I thought it would be worth a try - as the issue is comming from the object file (FDRS_Universal_Sensor.ino.o)
I added
#include "fdrs_sensor.cpp"
below the corresponding header file into the Sensor sketch and - voila, it compiles!
But... now I'm getting a new compiler error:
In file included from F:\dev\FDRS_UniversalSensor\FDRS_UniversalSensor.ino:18:0:
D:\dev\Arduino\libraries\Farm-Data-Relay-System\src/FDRS_Sensor/fdrs_sensor.cpp: In member function 'void FDRSBase::sleep(int)':
D:\dev\Arduino\libraries\Farm-Data-Relay-System\src/FDRS_Sensor/fdrs_sensor.cpp:69:33: error: 'sleep_time' was not declared in this scope
esp_sleep_enable_timer_wakeup(sleep_time * 1000000);
^
Which makes sense for me, as I couldn't find a place, where sleep_time
is actually defined. But then I am wondering why it compiles flawlessly, if the #define USE_LORA
is done in fdrs_sensor.h
file...
So still I do not understand what's going on.
Anyone who can help?
I'm still doomed with the undefined reference to vtable issue.
But the issue with the not declared sleep_time I fixed with https://github.com/timmbogner/Farm-Data-Relay-System/commit/c6b16143a9c7af95d752ef764e650040da8a202d
You tried installing and switching the "includes" to <includes>? That is my only thought. I assume Binder will have some insight...
You tried installing and switching the "includes" to
? That is my only thought. I assume Binder will have some insight...
I think so - actually I tried out all combinations I think. I just stepped one step back again and try to find a viable info about the include order of the Arduino IDE. Will share if I found out more.
@Gulpman, I get the same error. Here's what I did to resolve. I'm no expert but the issue must be the order in which the compile interprets the files.
Here's what I did and compiles properly on my Linux system using Arduino 1.8.19
Those steps seem to result in a successful compilation.
@Gulpman, I get the same error. Here's what I did to resolve. I'm no expert but the issue must be the order in which the compile interprets the files.
Definitively! I have read so many tutorials/documentations telling totally different stuff about how ArduinoIDE is handling compiling and linking... The consens was to use something different as the way Arduino IDE is handling this is somehow unpredictable.
OT: I would like to try out Platform.IO. From what I read, these kind of issues are explaind better when arising so fixing should be easier. As I think you are using Platform.IO (see #47 ;) ) - can you give a short summary on how to import this repo there? I tried to import it via the import dialogue but it complains that there is no .ino file.
Here's what I did and compiles properly on my Linux system using Arduino 1.8.19 [...] Those steps seem to result in a successful compilation.
Works! Thank you very much @aviateur17
I was playing around with the folder structure of the library in my local copy as I stumbled upon the Arduino library specification on my hunt for the root case as well. Reason is, that I'm unhappy with the fact, that each example holds the library files. I think they should be included from the library path (root dir or from a src subdir). I will need to test that approach a little bit more but overall I think this is something which must be done (get rid of redundancy) to have a clean project. Unfortunately I'm a noob on these things so I will not change it until I got it in my brain what the correct way to do it is. :)
But this topic can be closed - will open a new one on the structure if I know better.
Thanks again @aviateur17
Glad it worked for you! Going to VSCode and PlatformIO is a lot of work but well worth it in my opinion. I'm going on a week long holiday soon and so I don't have time to type up everything right now but I can do that in a week or so.
Basically
Here is basically my code for platformio.ini for ESP32. ESP8266 is a bit different.
[env:wemos_d1_mini32]
platform = espressif32
board = wemos_d1_mini32
framework = arduino
monitor_speed = 115200
lib_ldf_mode = ${common.lib_ldf_mode}
build_flags =
-DCORE_DEBUG_LEVEL=5
-DHOSTGENERAL
board_build.partitions = min_spiffs.csv
lib_deps = ${common.lib_deps}
board_build.f_cpu = ${common.board_build.f_cpu}
board_build.f_flash = ${common.board_build.f_flash}
[common]
lib_ldf_mode = deep ; #632 Fixes compiler error with OneBitDisplay library
build_flags =
-DCORE_DEBUG_LEVEL=5
lib_deps =
bblanchon/ArduinoJson @ ^6.17.3
sandeepmistry/LoRa@^0.8.0
board_build.f_cpu = 240000000L
board_build.f_flash = 80000000L
[platformio]
description =
default_envs = wemos_d1_mini32
platformio.ini for ESP8266 - I only have ESP01 or ESP01S boards
[env:esp01]
platform = espressif8266
board = esp01
lib_ldf_mode = deep ; #632 Fixes compiler error with OneBitDisplay library
board_build.f_cpu = 160000000L
board_build.f_flash = 80000000L
framework = arduino
monitor_speed = 76800
build_flags =
-DHOSTAABBCC
[platformio]
default_envs = esp01
I wanted to clean-up the configuration for the Universal_Sensor_beta. My intention was, that the user should not edit the class files but only the sensor sketch itself (.ino file) or the specific configuration file (fdrs_sensor_config.h).
In the current implementation of Universal_Sensor_beta the protocol being used can be activated by uncommenting one or the other
within
Farm-Data-Relay-System\examples\Universal_Sensor_beta\fdrs_sensor.h
Therefore I wanted to move the declaration, which protocoll the Universal_Sensor is supposed to use to the sensor configuration file:
Actually it is defined within fdrs_sensor.h, which compiles without issues.
The end user shouldn't edit fdrs_sensor.h. So I wanted to move the #define to fdrs_sensor_config.h:
But this leads to a compilation error:
I tried to do the define as first statement in the ino-file, to be 100% sure it is defined prior to any use of it but it throws the same compiler error.
I also tried to put the sketch and all includes into the root directory and into the src directory (in a temporary library, to be sure ther is no interference with anything else but I do still get the compile error.
@Devilbinder or anyone else: Can someone explain why the #define must be in the fdrs_sensor.h? And what can I do, to move it to the sketch or fdrs_sensor_config.h? Both of them should be known to fdrs_sensor.h or am I getting something wrong here?