ThingSet / thingset-device-library

ThingSet library for resource-constrained devices written in C/C++
https://thingset.io/thingset-device-library/
Apache License 2.0
13 stars 6 forks source link

thingset compile error when compiling for 8 bit AVR / Arduino #32

Closed stekgreif closed 2 years ago

stekgreif commented 2 years ago

I'm trying to include the thingset library into an Arduino Project.

The setup is

Compiling the code results in:

Archiving .pio/build/nanoatmega328/libFrameworkArduinoVariant.a
src/thingset_txt.c: In function 'ts_json_serialize_value':
src/thingset_txt.c:196:60: error: expected ')' before 'PRIu64'
                 pos += snprintf(buf + pos, size - pos, "%" PRIu64 ",",

Adding the build flags:

build_flags =
    -std=c++11
    -D NATIVE_BUILD
    -pthread
    -Wall
    -Wno-deprecated-declarations
    -D TS_64BIT_TYPES_SUPPORT=0```

to the platformio.ini file results in:

Compiling .pio/build/nanoatmega328/src/cbor.c.o
Compiling .pio/build/nanoatmega328/src/jsmn.c.o
avr-gcc: error: unrecognized command line option '-pthread'
avr-gcc: error: unrecognized command line option '-pthread'
Compiling .pio/build/nanoatmega328/src/main.cpp.o
*** [.pio/build/nanoatmega328/src/jsmn.c.o] Error 1
Compiling .pio/build/nanoatmega328/src/thingset.c.o
*** [.pio/build/nanoatmega328/src/cbor.c.o] Error 1
avr-g++: error: unrecognized command line option '-pthread'
*** [.pio/build/nanoatmega328/src/main.cpp.o] Error 1
avr-gcc: error: unrecognized command line option '-pthread'
*** [.pio/build/nanoatmega328/src/thingset.c.o] Error 1

Might be related to the 64 types for the AVR.

link to initial post: https://talk.libre.solar/t/thingset-on-8-bit-avr-arduino/338

martinjaeger commented 2 years ago

Thanks for reporting. It was indeed a bug. It's now fixed in main branch (see referenced commit above).

Can you please check again?

stekgreif commented 2 years ago

I still run into issues with strtoull and strtoll, I'm not sure if that's on my side. Here is the output:

/tmp/ccqrn51m.ltrans0.ltrans.o: In function `ts_json_deserialize_value.part.0':
<artificial>:(.text+0xf18): undefined reference to `strtoull'
<artificial>:(.text+0xf3e): undefined reference to `strtoll'
collect2: error: ld returned 1 exit status
*** [.pio/build/nanoatmega328/firmware.elf] Error 1
martinjaeger commented 2 years ago

Oops, yes, this is another one which won't work with no 64-bit support. Pushed another fix. Can you git pull again?

stekgreif commented 2 years ago

Nice, now it's compiling without errors. :+1: Thanks a lot.

Can't wait to get into it.

martinjaeger commented 2 years ago

Glad to hear that. Closing the issue now.