Undefined reference to class object during linking

This issue eludes me … once again. It is similar to one we looked at earlier, but the answer does not seem to be similar to the prior solution… https://community.platformio.org/t/undefined-reference-error-during-linking/28925

I have created a class to manage an ADC converter chip. That class is declared in ADS1216.h

class ADS1216_PD
{
public:
    // Constructors
    ADS1216_PD(int cs, int drdy);
    ADS1216_PD(SPIClass *s, int cs, int drdy);

   ...
   void setMux(ADS1216_MUX muxSetting);
 };


The functions are defined in ADS1216.cpp:

/* Constructors */
ADS1216_PD::ADS1216_PD(int cs, int drdy) : _spi{&SPI}, csPin{cs}, drdyPin{drdy} {}
ADS1216_PD::ADS1216_PD(SPIClass *s, int cs, int drdy) : _spi{s}, csPin{cs}, drdyPin{drdy} {}
...
void ADS1216_PD::setMux(ADS1216_MUX muxSetting)
{
    writeRegister(ADS1216_MUX_REG, muxSetting);
}



In main(), which lives in main.cpp, I call initialize(), which lives in initialize.cpp and initialize() creates the myADC object.

     #include "SPI.h"
    ADS1216_PD myADC = ADS1216_PD(PIN_ADC_CS_BAR, PIN_ADC_DRDY_BAR);

(Also in initialize I read and write some of the ADC registers, using other class functions not shown here, to confirm it is working) Now back in main(), after initialize completes, I go to call one of the myADC object functions.

#include <ADS1216.h>
extern ADS1216_PD myADC;

void setup()
{
  
  initialize();

  myADC.setMux(ADS1216_MUX_AIN3_AINCOM);
}

(Of course lots of other code is not shown here…) But it compiles fine and at link time throws this error:

c:/users/peted/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: .pio/build/esp32-s3-devkitc-1/src/main.cpp.o:(.literal._Z5setupv+0x0): 
undefined reference to `myADC'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\esp32-s3-devkitc-1\firmware.elf] Error 1

Commenting out the setMux call in main() and it compiles and runs fine.

What is odd is that this structure seems identical to another program I have linking just fine which used the ADS1220_WE library defining a similar object the same way. What am I missing here? (I have tried extern statements in several places to no avail). THANK YOU.

In the head-slapping category… I was really trying to make this a lot harder than necessary… I simply needed to move the instantiation of the object out of initialize()

initialize.cpp

 #include "SPI.h"
  ADS1216_PD myADC = ADS1216_PD(PIN_ADC_CS_BAR, PIN_ADC_DRDY_BAR);

 void initialize(void)
{
   // do other initializing stuff here
}

and in main.cpp add the extern line

main.cpp

#include <ADS1216.h>
extern ADS1216_PD myADC;


void setup()
{
 myADC.setMux(ADS1216_MUX_AIN3_AINCOM);
...
}