JSON Streaming Parser - compiler error "vtable" [SOLVED]

Trying to parse a potentially huge JSON and the “normal” parser isn’t handling it…
So this json-streaming-parser/examples/JsonStreamingParser at master · squix78/json-streaming-parser · GitHub looks like a good alternative, except it fails to compile in PIO (does compile fine in Arduino IDE).

Basically it dies at this line:
parser.setListener(&listener);
with this error:
Linking .pioenvs/nodemcuv2/firmware.elf
.pioenvs/nodemcuv2/src/main.cpp.o:(.data.listener+0x0): undefined reference to ``vtable for ExampleListener'

The library itself is hardly documented and quite complex (at least to me). The author uses it in his weather station - which doesn’t really help, because although those examples compile, they are giant, complex listings with only few comments…

Would appreciate any help, this is driving me nuts! :slight_smile:

You probably did not copy the ExampleParser.cpp/h files into your src/ directory. The example code compiles normally for me.

platformio.ini

[env:esp8266]
platform = espressif8266
board = nodemcuv2
framework = arduino
upload_speed = 460800 
build_unflags = -std=gnu99
build_flags = -std=gnu11
lib_deps = https://github.com/squix78/json-streaming-parser
DATA:    [====      ]  35.1% (used 28772 bytes from 81920 bytes)
PROGRAM: [==        ]  24.3% (used 253500 bytes from 1044464 bytes)
[SUCCESS] Took 25.40 seconds 
2 Likes

No I didn’t…
I put them in /include - changed to /src and BINGO!

Thanks a LOT!

Did you put the cpp source file into include/ instead of src too?

Yeah like you wrote - cpp and h.

No I meant before you changed them. Because I just put ExampleParser.cpp in the include/ directory and that gave me the same undefined reference to vtable for 'ExampleListener' error. This error is correct because source files placed in include/ are not compiled. Only those in src/ (or the libs) are.

Ah you mean the original Sketch?
I always copy it all over to main.cpp.
But usually /include is good enough for libraries, in this case since it’s a by-case-coding thing I guess it has to be in /src.