Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MostafaDadkhah opened this issue Feb 4, 2020 · 5 comments
Open

Comments

@MostafaDadkhah
Copy link

MostafaDadkhah commented Feb 4, 2020

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 of void 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 of void 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 of void 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 of void 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 of void 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
Copy link

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
Copy link

Rocco83 commented May 26, 2021

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

@Davidoff77test
Copy link

Davidoff77test commented May 27, 2021 via email

@tig
Copy link

tig commented Jun 28, 2021

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 added a commit to BOW-el/aREST that referenced this issue Apr 12, 2022
Standard structure of h and cpp file allows for using this library in more complex projects where several libraries need to link this file. aims at fixing marcoschwartz#278. 
Note: the code has not been changed as to my best knowledge, however, I needed to add anodher include ethernet.h in line 75 of the header file.
@BOW-el
Copy link

BOW-el commented Apr 12, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants