Skip to content

Duplicated declaration of mad_output_stream when linking #2

@vladkorotnev

Description

@vladkorotnev

Example to reproduce:

main.cpp

#include <netradio_mode.h>

InternetRadioMode test();

// ... other code does not matter ...

netradio_mode.h

#pragma once
#include "AudioTools/AudioCodecs/CodecMP3MAD.h"

class InternetRadioMode {
public:
    InternetRadioMode();

private:
    MP3DecoderMAD codec;
};

netradio_mode.cpp

#include <netradio_mode.h>
InternetRadioMode::InternetRadioMode():
    codec() {
}

Expected outcome

Project builds, class InternetRadioMode has a codec of type MP3DecoderMAD.

Actual outcome

Duplicate symbols prevent project from building. Probably the plan was to make them extern or such? (there is a #pragma once in the offending header though, so I am puzzled why this happens)

c:/users/akasaka/.platformio/packages/[email protected]+2021r2-patch5/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\src\mode\netradio_mode.cpp.o:(.bss._ZN6libmad17mad_output_streamE+0x0): multiple definition of `libmad::mad_output_stream'; .pio\build\esp32dev\src\main.cpp.o:(.bss._ZN6libmad17mad_output_streamE+0x0): first defined here
c:/users/akasaka/.platformio/packages/[email protected]+2021r2-patch5/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\src\mode\netradio_mode.cpp.o:(.bss._ZN6libmad12infoCallbackE+0x0): multiple definition of `libmad::infoCallback'; .pio\build\esp32dev\src\main.cpp.o:(.bss._ZN6libmad12infoCallbackE+0x0): first defined here
c:/users/akasaka/.platformio/packages/[email protected]+2021r2-patch5/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp32dev\src\mode\netradio_mode.cpp.o:(.bss._ZN6libmad11pwmCallbackE+0x0): multiple definition of `libmad::pwmCallback'; .pio\build\esp32dev\src\main.cpp.o:(.bss._ZN6libmad11pwmCallbackE+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\esp32dev\firmware.elf] Error 1

Environment

Arduino for ESP32 under PlatformIO

build config

[env:esp32dev]
build_flags = -DBOARD_HAS_PSRAM -DCONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY -O3 -DCORE_DEBUG_LEVEL=3 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -Wno-format-extra-args
platform = espressif32
framework = arduino
board = esp32dev
build_type = debug
lib_deps = 
    ArduinoAudioTools=https://github.com/pschatzmann/arduino-audio-tools.git#496a9f2
    libmad=https://github.com/pschatzmann/arduino-libmad.git

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions