Errors compiling sqlite3Esp32 library examples

Hi. I can’t compile sqlite3.c. When I compile the result are multiple warnings and errors. I’m using heltec wifi kit 32. I’m trying to compile the examples without results.
My platformio.ini:

[env:heltec_wifi_kit_32]
platform = espressif32
board = heltec_wifi_kit_32
framework = arduino
lib_deps = Sqlite3Esp32

and the result:

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/heltec_wifi_kit_32.html
PLATFORM: Espressif 32 1.12.4 > Heltec WiFi Kit 32
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10004.200129 (1.0.4)
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 40 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Sqlite3Esp32> 2.2
|   |-- <Time> 1.5    
|-- <SD(esp32)> 1.0.5 
|   |-- <FS> 1.0      
|   |-- <SPI> 1.0     
|-- <SD_MMC> 1.0      
|   |-- <FS> 1.0      
|-- <SPIFFS> 1.0
|   |-- <FS> 1.0
|-- <FS> 1.0
|-- <SPI> 1.0
|-- <Time> 1.5
Building in release mode
Compiling .pio\build\heltec_wifi_kit_32\src\main.cpp.o
Generating partitions .pio\build\heltec_wifi_kit_32\partitions.bin
Compiling .pio\build\heltec_wifi_kit_32\lib695\Time\DateStrings.cpp.o
Compiling .pio\build\heltec_wifi_kit_32\lib695\Time\Time.cpp.o
Compiling .pio\build\heltec_wifi_kit_32\libf11\Sqlite3Esp32\esp32.cpp.o
Compiling .pio\build\heltec_wifi_kit_32\libf11\Sqlite3Esp32\shox96_0_2.cpp.o
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\shox96_0_2.cpp: In function 'int shox96_0_2_compress(const char*, int, char*, lnk_lst*)':
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\shox96_0_2.cpp:274:44: warning: array subscript has type 'char' [-Wchar-subscripts]
         ol = append_bits(out, ol, c_95[c_in], l_95[c_in], state);
                                            ^
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\shox96_0_2.cpp:274:56: warning: array subscript has type 'char' [-Wchar-subscripts]
         ol = append_bits(out, ol, c_95[c_in], l_95[c_in], state);
                                                        ^
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\shox96_0_2.cpp: In function 'int shox96_0_2_decompress(const char*, int, char*, lnk_lst*)':
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\shox96_0_2.cpp:446:16: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
         c -= 32;
                ^
Compiling .pio\build\heltec_wifi_kit_32\libf11\Sqlite3Esp32\sqlite3.c.o
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\sqlite3.c:22047:42: warning: 'struct tm' declared inside parameter list
 static int osLocaltime(time_t *t, struct tm *pTm){
                                          ^
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\sqlite3.c:22047:42: warning: its scope is only this definition or declaration, which is probably not what you want
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\sqlite3.c: In function 'osLocaltime':
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\sqlite3.c:22055:8: warning: implicit declaration of function 'localtime' [-Wimplicit-function-declaration]
   pX = localtime(t);
        ^
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\sqlite3.c:22055:6: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
   pX = localtime(t);
      ^
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\sqlite3.c:22059:11: error: dereferencing pointer to incomplete type 'struct tm'
  if( pX ) *pTm = *pX;
           ^
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\sqlite3.c: In function 'localtimeOffset':
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\sqlite3.c:22093:13: error: storage size of 'sLocal' isn't known
   struct tm sLocal;
             ^
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\sqlite3.c:22093:13: warning: unused variable 'sLocal' [-Wunused-variable]
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\esp32.cpp: In function 'int ESP32Read(sqlite3_file*, void*, int, sqlite_int64)':
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\esp32.cpp:164:9: warning: variable 'ofst' set but not used [-Wunused-but-set-variable]
   off_t ofst;                     /* Return value from lseek() */
         ^
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\esp32.cpp: In function 'int ESP32FileSize(sqlite3_file*, sqlite_int64*)':
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\esp32.cpp:289:15: warning: unused variable 'sStat' [-Wunused-variable]
   struct stat sStat;              /* Output of fstat() call */
               ^
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\esp32.cpp: In function 'int ESP32Open(sqlite3_vfs*, const char*, sqlite3_file*, int, int*)':
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\esp32.cpp:413:7: warning: unused variable 'oflags' [-Wunused-variable]
   int oflags = 0;                 /* flags to pass to open() call */
       ^
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\esp32.cpp: In function 'int ESP32CurrentTime(sqlite3_vfs*, double*)':
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\esp32.cpp:595:20: error: 'time' was not declared in this scope
   time_t t = time(0);
                    ^
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\esp32.cpp: In function 'void shox96_0_2d(sqlite3_context*, int, sqlite3_value**)':
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\esp32.cpp:650:27: warning: unused variable 'rc' [-Wunused-variable]
   unsigned int nIn, nOut, rc;
                           ^
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\esp32.cpp: In function 'void unishox1d(sqlite3_context*, int, sqlite3_value**)':
C:\Users\Papa\.platformio\lib\Sqlite3Esp32\src\esp32.cpp:700:27: warning: unused variable 'rc' [-Wunused-variable]
   unsigned int nIn, nOut, rc;
                           ^
*** [.pio\build\heltec_wifi_kit_32\libf11\Sqlite3Esp32\esp32.cpp.o] Error 1
*** [.pio\build\heltec_wifi_kit_32\libf11\Sqlite3Esp32\sqlite3.c.o] Error 1

Thanks and regards

Yeah the infamous Arduino “Time” library with Time.h which collidies with the C-standard time.h header has been the topic of many post here. Do things look better when you write lib_ignore = Time in the platformio.ini?

1 Like

OK thanks. That is the solution. Now the examples compile without errors, although some warnings.
I’m newbie in this community and have not yet seen this problem. From now on I will consider it.
Thanks maxgerhardt for your help. :ok_hand:

If I ignore Time lib, How when I need also the Time library ?

You place a copy if it in the lib/ folder but delete the Time.h header and only refer to it via the TimeLib.h header (source).

@maxgerhardt

It is an infamous error. I losting my head on it and I have not solved yet.

I need these libraries :

...
#include <sqlite3.h>
#include "TimeLib.h"
#include <TimeAlarms.h>
... (and others)

The lib_deps_external section on platformio.ini

paulstoffregen/Time @ ^1.6
paulstoffregen/TimeAlarms@0.0.0-alpha+sha.c291c1ddad
sandeepmistry/LoRa@^0.7.2
knolleary/PubSubClient@^2.8
bblanchon/ArduinoJson@^6.17.2
siara-cc/Sqlite3Esp32 @ ^2.3
.... (and others)

and added also lib_ignore = Time

Into lib folder I have copied from .pio\libdeps\myproject\Time folder

DateStrings.cpp
Time.cpp
TimeLib.h

But the build fail miserably.

.pio\libdeps\sas-gateway-ttgo\TimeAlarms\TimeAlarms.h:7:21: fatal error: TimeLib.h: No such file or directory

Can you give me an hand, please ?

Thank’s

Remove this line for the platformio.ini as well as lib_ignore = Time. Remove the complete .pio folder of the project. Then create a folder Time in lib/ and fill it with the content from https://github.com/PaulStoffregen/Time/archive/master.zip, but remove the Time.h file. Rebuild the project.

Thanks, but same error.

Compiling .pio\build\sas-gateway-ttgo\libe77\Wire\Wire.cpp.o
In file included from .pio\libdeps\sas-gateway-ttgo\TimeAlarms\TimeAlarms.cpp:21:0:
.pio\libdeps\sas-gateway-ttgo\TimeAlarms\TimeAlarms.h:7:21: fatal error: TimeLib.h: No such file or directory

`

[common]

lib_deps_external =
;paulstoffregen/Time @ ^1.6
paulstoffregen/TimeAlarms@0.0.0-alpha+sha.c291c1ddad
adafruit/Adafruit BusIO@^1.6.0
adafruit/Adafruit SSD1306@^2.4.0
sandeepmistry/LoRa@^0.7.2
knolleary/PubSubClient@^2.8
bblanchon/ArduinoJson@^6.17.2
siara-cc/Sqlite3Esp32 @ ^2.3
;GitHub - lorol/LITTLEFS: LittleFS library for arduino-esp32
GitHub - lorol/LITTLEFS: LittleFS library for arduino-esp32
vshymanskyy/TinyGSM@^0.10.9
vshymanskyy/StreamDebugger@^1.0.1

lib_ignore = Time
`

You still lib_ignore it.

Build is OK !

You are a genius.

GRAZIE. :slight_smile: