pschatzmann / arduino-audio-tools

Arduino Audio Tools (a powerful Audio library not only for Arduino)
GNU General Public License v3.0
1.55k stars 237 forks source link

Issue linking library with esphome components #448

Closed P4uLT closed 2 years ago

P4uLT commented 2 years ago

Hello,

First of all I would to thank you for this great project! I'm currently trying to integrate your library into a custom components into Esphome.

I created some empty component and and have some issue compiling / linking it.

To be clear I'm a quite new to C/C++ development so maybe what I try to do is wrong ;)

I'm using the latest tag : v0.9.2

My files are quite simple :

rhasspy_satellite.h

#pragma once

#include "esphome/core/component.h"

//#include <AudioTools.h> <- not working

#endif

namespace esphome {
namespace rhasspy_satellite {

class RhasspySatelliteComponent : public Component {
 public:
  void setup() override;
  void loop() override;
  void dump_config() override;
};

}  // namespace rhasspy_satellite
}  // namespace esphome

rhasspy_satellite.cpp

#include "esphome/core/log.h"
#include "rhasspy_satellite.h"

//#include <AudioTools.h> <-- working

namespace esphome {
namespace rhasspy_satellite {

static const char *const TAG = "rhasspy_satellite.component";

audio_tools::I2SStream in;

void RhasspySatelliteComponent::setup() {}

void RhasspySatelliteComponent::loop() {}

void RhasspySatelliteComponent::dump_config() { ESP_LOGCONFIG(TAG, "RhasspySatellite Component"); }

}  // namespace rhasspy_satellite
}  // namespace esphome

When I set the include into the cpp file it's working, I have other samples based on this one working too on an ESP32 with I2S.

When I set it into the .h I got the following error :

Linking .pioenvs/esp32-i2s-audio-nodemcu/firmware.elf
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o: In function `audio_tools::defaultPWMAudioOutputCallback()':
/workspaces/esphome-rhasspy/.build/esp32-i2s-audio-nodemcu/.piolibdeps/esp32-i2s-audio-nodemcu/audio-tools/src/AudioTools/Buffers.h:36: multiple definition of `audio_tools::defaultPWMAudioOutputCallback()'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:/workspaces/esphome-rhasspy/.build/esp32-i2s-audio-nodemcu/.piolibdeps/esp32-i2s-audio-nodemcu/audio-tools/src/AudioPWM/PWMAudioESP32.h:153: first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools15MetaDataTypeStrE+0x0): multiple definition of `audio_tools::MetaDataTypeStr'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools15MetaDataTypeStrE+0x0): first defined here

.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o: In function `audio_tools::toStr(audio_tools::MetaDataType)':
main.cpp:(.text._ZN11audio_tools5toStrENS_12MetaDataTypeE+0x0): multiple definition of `audio_tools::toStr(audio_tools::MetaDataType)'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:rhasspy_satellite.cpp:(.text._ZN11audio_tools5toStrENS_12MetaDataTypeE+0x0): first defined here

.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o: In function `waitFor(HardwareSerial&)':
main.cpp:(.text._Z7waitForR14HardwareSerial+0x0): multiple definition of `waitFor(HardwareSerial&)'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:rhasspy_satellite.cpp:(.text._Z7waitForR14HardwareSerial+0x0): first defined here

.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o: In function `waitFor(bool&)':
main.cpp:(.text._Z7waitForRb+0x0): multiple definition of `waitFor(bool&)'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:rhasspy_satellite.cpp:(.text._Z7waitForRb+0x0): first defined here

.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o: In function `audio_tools::TimerCallbackAudioStream::timerCallback(void*)':
main.cpp:(.iram1.27+0x0): multiple definition of `audio_tools::TimerCallbackAudioStream::timerCallback(void*)'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:rhasspy_satellite.cpp:(.iram1.27+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.bss._ZN11audio_tools14default_configE+0x0): multiple definition of `audio_tools::default_config'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.bss._ZN11audio_tools14default_configE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools8wav_mimeE+0x0): multiple definition of `audio_tools::wav_mime'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools8wav_mimeE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools11id3_v2_tagsE+0x0): multiple definition of `audio_tools::id3_v2_tags'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools11id3_v2_tagsE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools6genresE+0x0): multiple definition of `audio_tools::genres'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools6genresE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools7methodsE+0x0): multiple definition of `audio_tools::methods'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools7methodsE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools8LOCATIONE+0x0): multiple definition of `audio_tools::LOCATION'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools8LOCATIONE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools8IDENTITYE+0x0): multiple definition of `audio_tools::IDENTITY'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools8IDENTITYE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools15ACCEPT_ENCODINGE+0x0): multiple definition of `audio_tools::ACCEPT_ENCODING'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools15ACCEPT_ENCODINGE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools6HOST_CE+0x0): multiple definition of `audio_tools::HOST_C'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools6HOST_CE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools13DEFAULT_AGENTE+0x0): multiple definition of `audio_tools::DEFAULT_AGENT'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools13DEFAULT_AGENTE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools10USER_AGENTE+0x0): multiple definition of `audio_tools::USER_AGENT'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools10USER_AGENTE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools7SUCCESSE+0x0): multiple definition of `audio_tools::SUCCESS'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools7SUCCESSE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools10ACCEPT_ALLE+0x0): multiple definition of `audio_tools::ACCEPT_ALL'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools10ACCEPT_ALLE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools6ACCEPTE+0x0): multiple definition of `audio_tools::ACCEPT'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools6ACCEPTE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools7CHUNKEDE+0x0): multiple definition of `audio_tools::CHUNKED'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools7CHUNKEDE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools17TRANSFER_ENCODINGE+0x0): multiple definition of `audio_tools::TRANSFER_ENCODING'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools17TRANSFER_ENCODINGE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools14CON_KEEP_ALIVEE+0x0): multiple definition of `audio_tools::CON_KEEP_ALIVE'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools14CON_KEEP_ALIVEE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools9CON_CLOSEE+0x0): multiple definition of `audio_tools::CON_CLOSE'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools9CON_CLOSEE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools10CONNECTIONE+0x0): multiple definition of `audio_tools::CONNECTION'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools10CONNECTIONE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools14CONTENT_LENGTHE+0x0): multiple definition of `audio_tools::CONTENT_LENGTH'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools14CONTENT_LENGTHE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools12CONTENT_TYPEE+0x0): multiple definition of `audio_tools::CONTENT_TYPE'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools12CONTENT_TYPEE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools11i2s_formatsE+0x0): multiple definition of `audio_tools::i2s_formats'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools11i2s_formatsE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.bss._ZN11audio_tools18timerCallbackArrayE+0x0): multiple definition of `audio_tools::timerCallbackArray'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.bss._ZN11audio_tools18timerCallbackArrayE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.bss._ZN11audio_tools18simpleUserCallbackE+0x0): multiple definition of `audio_tools::simpleUserCallback'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.bss._ZN11audio_tools18simpleUserCallbackE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools8mime_pcmE+0x0): multiple definition of `audio_tools::mime_pcm'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools8mime_pcmE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools13RxTxModeNamesE+0x0): multiple definition of `audio_tools::RxTxModeNames'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools13RxTxModeNamesE+0x0): first defined here
collect2: error: ld returned 1 exit status
*** [.pioenvs/esp32-i2s-audio-nodemcu/firmware.elf] Error 1

Did you already have this kind of issue ?

Thanks for your help!

pschatzmann commented 2 years ago

Are you you sure that you used the latest version of the library? The global variables have been changed to be inline, so you should not get these linker errors

P4uLT commented 2 years ago

I'm using this tag : https://github.com/pschatzmann/arduino-audio-tools/releases/tag/v0.9.2 What is strange to me is why I can use it directly into .cpp file and not into a .h one ( maybe my question is a dumb one :D )

On Top of that I saw this but I didnt use any build_flags

pschatzmann commented 2 years ago

I suggest that you use the latest main branch. I have not released this change yet...

P4uLT commented 2 years ago

The main branch + -DINGNORE_INLINE_VARS as build_flags :

.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o: In function `audio_tools::sine(float)':
/workspaces/esphome-rhasspy/.build/esp32-i2s-audio-nodemcu/.piolibdeps/esp32-i2s-audio-nodemcu/audio-tools/src/AudioEffects/SoundGenerator.h:265: multiple definition of `audio_tools::sine(float)'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:/workspaces/esphome-rhasspy/.build/esp32-i2s-audio-nodemcu/.piolibdeps/esp32-i2s-audio-nodemcu/audio-tools/src/AudioEffects/SoundGenerator.h:265: first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools15MetaDataTypeStrE+0x0): multiple definition of `audio_tools::MetaDataTypeStr'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools15MetaDataTypeStrE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o: In function `audio_tools::toStr(audio_tools::MetaDataType)':
main.cpp:(.text._ZN11audio_tools5toStrENS_12MetaDataTypeE+0x0): multiple definition of `audio_tools::toStr(audio_tools::MetaDataType)'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:rhasspy_satellite.cpp:(.text._ZN11audio_tools5toStrENS_12MetaDataTypeE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.bss._ZN11audio_tools14default_configE+0x0): multiple definition of `audio_tools::default_config'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.bss._ZN11audio_tools14default_configE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools8wav_mimeE+0x0): multiple definition of `audio_tools::wav_mime'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools8wav_mimeE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools11id3_v2_tagsE+0x0): multiple definition of `audio_tools::id3_v2_tags'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools11id3_v2_tagsE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools6genresE+0x0): multiple definition of `audio_tools::genres'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools6genresE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools7methodsE+0x0): multiple definition of `audio_tools::methods'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools7methodsE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools8LOCATIONE+0x0): multiple definition of `audio_tools::LOCATION'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools8LOCATIONE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools8IDENTITYE+0x0): multiple definition of `audio_tools::IDENTITY'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools8IDENTITYE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools15ACCEPT_ENCODINGE+0x0): multiple definition of `audio_tools::ACCEPT_ENCODING'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools15ACCEPT_ENCODINGE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools6HOST_CE+0x0): multiple definition of `audio_tools::HOST_C'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools6HOST_CE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools13DEFAULT_AGENTE+0x0): multiple definition of `audio_tools::DEFAULT_AGENT'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools13DEFAULT_AGENTE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools10USER_AGENTE+0x0): multiple definition of `audio_tools::USER_AGENT'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools10USER_AGENTE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools7SUCCESSE+0x0): multiple definition of `audio_tools::SUCCESS'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools7SUCCESSE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools10ACCEPT_ALLE+0x0): multiple definition of `audio_tools::ACCEPT_ALL'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools10ACCEPT_ALLE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools6ACCEPTE+0x0): multiple definition of `audio_tools::ACCEPT'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools6ACCEPTE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools7CHUNKEDE+0x0): multiple definition of `audio_tools::CHUNKED'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools7CHUNKEDE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools17TRANSFER_ENCODINGE+0x0): multiple definition of `audio_tools::TRANSFER_ENCODING'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools17TRANSFER_ENCODINGE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools14CON_KEEP_ALIVEE+0x0): multiple definition of `audio_tools::CON_KEEP_ALIVE'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools14CON_KEEP_ALIVEE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools9CON_CLOSEE+0x0): multiple definition of `audio_tools::CON_CLOSE'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools9CON_CLOSEE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools10CONNECTIONE+0x0): multiple definition of `audio_tools::CONNECTION'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools10CONNECTIONE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools14CONTENT_LENGTHE+0x0): multiple definition of `audio_tools::CONTENT_LENGTH'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools14CONTENT_LENGTHE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools12CONTENT_TYPEE+0x0): multiple definition of `audio_tools::CONTENT_TYPE'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools12CONTENT_TYPEE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools11i2s_formatsE+0x0): multiple definition of `audio_tools::i2s_formats'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools11i2s_formatsE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.bss._ZN11audio_tools18timerCallbackArrayE+0x0): multiple definition of `audio_tools::timerCallbackArray'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.bss._ZN11audio_tools18timerCallbackArrayE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.bss._ZN11audio_tools18simpleUserCallbackE+0x0): multiple definition of `audio_tools::simpleUserCallback'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.bss._ZN11audio_tools18simpleUserCallbackE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools8mime_pcmE+0x0): multiple definition of `audio_tools::mime_pcm'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools8mime_pcmE+0x0): first defined here
.pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o:(.data._ZN11audio_tools13RxTxModeNamesE+0x0): multiple definition of `audio_tools::RxTxModeNames'
.pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:(.data._ZN11audio_tools13RxTxModeNamesE+0x0): first defined here
collect2: error: ld returned 1 exit status
*** [.pioenvs/esp32-i2s-audio-nodemcu/firmware.elf] Error 1

Seems quite the same.

pschatzmann commented 2 years ago

They need to be inline: So your flag does not make any sense! Otherwise all needs to be in one compilation unit...

P4uLT commented 2 years ago

When removing the flag I have all previous variables in error like this one :


In file included from .piolibdeps/esp32-i2s-audio-nodemcu/audio-tools/src/AudioCodecs/AudioCodecs.h:3:0,
                 from .piolibdeps/esp32-i2s-audio-nodemcu/audio-tools/src/AudioTools.h:29,
                 from src/esphome/components/rhasspy_satellite/rhasspy_satellite.h:5,
                 from src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp:2:
.piolibdeps/esp32-i2s-audio-nodemcu/audio-tools/src/AudioCodecs/CodecWAV.h:34:24: error: 'audio_tools::wav_mime' declared as an 'inline' variable
pschatzmann commented 2 years ago

Did you use platform = https://github.com/platformio/platform-espressif32.git You need to have at least C++17

P4uLT commented 2 years ago

In the latest version of esphome, the framework set it to https://github.com/platformio/platform-espressif32/tree/v3.5.0 automatically.

I will check if Its possible to upgrade it safely.

pschatzmann commented 2 years ago

Maybe you can also force C++17 with a compiler flag

P4uLT commented 2 years ago

A quick update on my side :

I managed to update some versions.

    platform: platformio/espressif32 @ 5.2.0
    platform_packages:
      - "platformio/framework-arduinoespressif32 @ 2.0.5"

I have less errors, just one standing :

Linking .pioenvs/esp32-i2s-audio-nodemcu/firmware.elf
/esphome/.temp/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/esp32-i2s-audio-nodemcu/src/main.cpp.o: in function `audio_tools::sine(float)':
/workspaces/esphome-rhasspy/.build/esp32-i2s-audio-nodemcu/.piolibdeps/esp32-i2s-audio-nodemcu/audio-tools/src/AudioEffects/SoundGenerator.h:265: multiple definition of `audio_tools::sine(float)'; .pioenvs/esp32-i2s-audio-nodemcu/src/esphome/components/rhasspy_satellite/rhasspy_satellite.cpp.o:/workspaces/esphome-rhasspy/.build/esp32-i2s-audio-nodemcu/.piolibdeps/esp32-i2s-audio-nodemcu/audio-tools/src/AudioEffects/SoundGenerator.h:265: first defined here
collect2: error: ld returned 1 exit status

I tried -std=c++17 and -std=gnu++17 without success.

One last idea ? :+1:

pschatzmann commented 2 years ago

Can you double check if it helps to define this method as inline ? This got added lately by a pull request...

P4uLT commented 2 years ago

Congratz !

Linking .pioenvs/esp32-i2s-audio-nodemcu/firmware.elf
RAM:   [=         ]  14.6% (used 47828 bytes from 327680 bytes)
Flash: [======    ]  60.8% (used 1115465 bytes from 1835008 bytes)
Building .pioenvs/esp32-i2s-audio-nodemcu/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs/esp32-i2s-audio-nodemcu/firmware.bin"], [".pioenvs/esp32-i2s-audio-nodemcu/firmware.elf"])
Flash params set to 0x0020
Wrote 0x121bd0 bytes to file /workspaces/esphome-rhasspy/.build/esp32-i2s-audio-nodemcu/.pioenvs/esp32-i2s-audio-nodemcu/firmware-factory.bin, ready to flash to offset 0x0
===================================================== [SUCCESS] Took 91.51 seconds =====================================================

A big thank you!

I can make a PR if you need.

pschatzmann commented 2 years ago

Cool. I just committed a correction. I didn't like to have sine() as global method anyhow, so I moved it into the FastSineGenerator class