marcoschwartz / aREST

A RESTful environment for Arduino
http://aREST.io/
Other
1.2k stars 279 forks source link

multiple definition of void aREST::addToBuffer in PlatformIO #278

Open MostafaDadkhah opened 4 years ago

MostafaDadkhah commented 4 years ago

Hi I can't work with this library in PlatformIO. When building, I encounter the following Errors. What should I do?

Processing nodemcuv2 (platform: espressif8266; board: nodemcuv2; framework: arduino)

Verbose mode can be enabled via -v, --verbose option CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/nodemcuv2.html PLATFORM: Espressif 8266 2.3.2 > NodeMCU 1.0 (ESP-12E Module) HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash PACKAGES: toolchain-xtensa 2.40802.191122 (4.8.2), tool-esptool 1.413.0 (4.13), tool-esptoolpy 1.20800.0 (2.8.0), framework-arduinoespressif8266 2.20603.191216 (2.6.3) LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf LDF Modes: Finder ~ chain, Compatibility ~ soft Found 39 compatible libraries Scanning dependencies... Dependency Graph |-- 3.3.3 | |-- 1.0 | |-- 6.4.0 |-- 2.2.0 | |-- 1.0 | |-- <Ethernet(esp8266)> 1.0.4 | | |-- 1.0 | |-- 1.0 | |-- 1.0 |-- |-- | |-- 1.0 |-- | |-- | |-- 1.0 |-- | |-- | | |-- 2.2.0 | | | |-- 1.0 | | | |-- <Ethernet(esp8266)> 1.0.4 | | | | |-- 1.0 | | | |-- 1.0 | | | |-- 1.0 |-- |-- | |-- 2.2.0 | | |-- 1.0 | | |-- <Ethernet(esp8266)> 1.0.4 | | | |-- 1.0 | | |-- 1.0 | | |-- 1.0 |-- | |-- 3.3.3 | | |-- 1.0 | | |-- 6.4.0 Building in release mode Linking .pio/build/nodemcuv2/firmware.elf /Users/mostafadadkhah/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib900/libSetAPMode.a(SetAPMode.cpp.o): in function void aREST::addToBuffer<bool>(bool, bool)': SetAPMode.cpp:(.text._ZN5aREST11addToBufferIbEEvT_b+0xc): multiple definition ofvoid aREST::addToBuffer(bool, bool)'; .pio/build/nodemcuv2/src/main.cpp.o:main.cpp:(.text._ZN5aREST11addToBufferIbEEvT_b+0xc): first defined here /Users/mostafadadkhah/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib900/libSetAPMode.a(SetAPMode.cpp.o): in function void aREST::addToBuffer<char const*>(char const*, bool)': SetAPMode.cpp:(.text._ZN5aREST11addToBufferIPKcEEvT_b+0x4): multiple definition ofvoid aREST::addToBuffer<char const>(char const, bool)'; .pio/build/nodemcuv2/src/main.cpp.o:main.cpp:(.text._ZN5aREST11addToBufferIPKcEEvT_b+0x4): first defined here /Users/mostafadadkhah/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib900/libSetAPMode.a(SetAPMode.cpp.o): in function void aREST::addToBuffer<String const*>(String const*, bool)': SetAPMode.cpp:(.text._ZN5aREST11addToBufferIPK6StringEEvT_b+0x4): multiple definition ofvoid aREST::addToBuffer<String const>(String const, bool)'; .pio/build/nodemcuv2/src/main.cpp.o:main.cpp:(.text._ZN5aREST11addToBufferIPK6StringEEvT_b+0x4): first defined here /Users/mostafadadkhah/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib900/libSetAPMode.a(SetAPMode.cpp.o): in function void aREST::addToBuffer<String>(String, bool)': SetAPMode.cpp:(.text._ZN5aREST11addToBufferI6StringEEvT_b+0x4): multiple definition ofvoid aREST::addToBuffer(String, bool)'; .pio/build/nodemcuv2/src/main.cpp.o:main.cpp:(.text._ZN5aREST11addToBufferI6StringEEvT_b+0x4): first defined here /Users/mostafadadkhah/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/nodemcuv2/lib900/libSetAPMode.a(SetAPMode.cpp.o): in function void aREST::addToBuffer<char*>(char*, bool)': SetAPMode.cpp:(.text._ZN5aREST11addToBufferIPcEEvT_b+0x4): multiple definition ofvoid aREST::addToBuffer<char>(char, bool)'; .pio/build/nodemcuv2/src/main.cpp.o:main.cpp:(.text._ZN5aREST11addToBufferIPcEEvT_b+0x4): first defined here collect2: error: ld returned 1 exit status *** [.pio/build/nodemcuv2/firmware.elf] Error 1 ========================================== [FAILED] Took 2.81 seconds ========================================== The terminal process terminated with exit code: 1

Davidoff77test commented 3 years ago

There is one big bug in this library. Definition and declaration is in one file. So, when you you use aREST.h in more file... linker won't work.

Rocco83 commented 3 years ago

@marcoschwartz do you agree? would you agree on splitting the lib into .h and .cpp file?

Davidoff77test commented 3 years ago

Yes, it will be nice.

Thnx

D. ---------- Původní e-mail ---------- Od: Daniele Palumbo @.> Komu: marcoschwartz/aREST @.> Datum: 26. 5. 2021 18:20:44 Předmět: Re: [marcoschwartz/aREST] multiple definition of void aREST:: addToBuffer in PlatformIO (#278) "

@marcoschwartz(https://github.com/marcoschwartz) do you agree? would you agree on splitting the lib into .h and .cpp file?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub (https://github.com/marcoschwartz/aREST/issues/278#issuecomment-848912265), or unsubscribe (https://github.com/notifications/unsubscribe-auth/AAHACVK2HMNUOHSYR2DZXRLTPUNVNANCNFSM4KPTAENQ) . "

tig commented 3 years ago

I just spent several hours trying to figure this out.

This makes it impossible to have multiple source files in a platformio project.

Has anyone figured out a work around?

BOW-el commented 2 years ago

I've stumbled upon the same problem and went ahead to split up the header into several files. Result is in the abovementioned pull request that seems to work well for me so far.