Compile Error "undefined reference to constructor"

I couldn’t find a solution search for it on the internet or asking a AI…
DefineEnum.h

#ifndef DefineEnum_h
#define DefineEnum_h
//Mux / Portexpander
#define MUXBACK_ADDR 0x70
#define MUXFRONT_ADDR 0x71
#endif

General.h

#ifndef General_h
#define General_h

//Defines & Enums
#include "DefineEnum.h"
//TOF
#include "../TOF/TOF/TOF.h"

class Robot{
public: 
TOFonMux TOF[8];
Robot();
}

General.cpp

#include "General.h"

Robot::Robot() : //Member Initializer List
    TOF{
        TOFonMux(0, &muxBack),
        TOFonMux(1, &muxBack),
        TOFonMux(2, &muxBack),
        TOFonMux(3, &muxBack),
        TOFonMux(4, &muxFront),
        TOFonMux(5, &muxFront),
        TOFonMux(6, &muxFront),
        TOFonMux(7, &muxFront)
    }
    //Mux
    muxBack.begin(MUXBACK_ADDR);
    muxFront.begin(MUXFRONT_ADDR);
}

#endif

TOF.h

#ifndef TOF_h
#define TOF_h

#include "../Adafruit_VL6180X-master/Adafruit_VL6180X.h"
#include "../General/DefineEnum.h" //Warum will VScode nur 2 "."? Es sollten 3 sein!
#include "../Portexpander/src/SparkFun_I2C_Mux_Arduino_Library.h"

class TOFonMux : public Adafruit_VL6180X{
    public:
    TOFonMux(uint8_t pinOnMux, QWIICMUX *expander);
    TOFonMux();

    uint8_t range;
    private:
    uint8_t pin;
    QWIICMUX *expander;
};
#endif

TOF.cpp

#include "TOF.h"

TOFonMux::TOFonMux(uint8_t pinOnMux, QWIICMUX *expander) : Adafruit_VL6180X() {
    this->expander = expander;
    this->pin = pinOnMux;
};

TOFonMux::TOFonMux(){
    this->expander = NULL;
    this->pin = 9; //Expander/Mux only has ports from 0-7
};

I cut some of the code in the general-files & DefineEnum.h for this post that didn’t seem relevant to the problem.

General.h is than included in main.cpp of course

The files provided are not sufficient for testing as there are other dependencies which are not listed. Please provide a simplified project that only refers to the problem and can be compiled on its own.

What other dependencies? The expander and tof libary?
I can send them in but they’re just the public ones from adafruit.

I should also maybe send a screenshot of the compiler error

Little more info:


Expander , Expander lib

TOF, TOF lib
(Had to do it in to messages because I’m a new user)

I am unable to reproduce your project because of missing files and dependencies. It would be much more easy for me to have the complete project - including your platformio.ini.

In addition your project is a bit strange about your library setup. It would be really much more easy to have either the complete project or a bare minimal project to reproduce the error.

Can you make the folder structure such that you just have

TOF 
  - TOF.cpp
  - TOF.h

(single level) and the Adafruit VL6180x (master) library just inserted via lib_deps?

PlatformIO might get confused because the Adafruit_VL6180X-master folder has the actual library.properties or library.json, so it may never even compile TOF.cpp.

1 Like

I already did, but there are still missing files and depenencies. That’s why I am asking for the complete project.

It’s exhausting having to rebuild everything by hand and searching for the matching libraries.

Solved by max :slight_smile:

thx. Moving it to seperate folders worked! :+1: (Even though I have similar folders that work)
I’ll set up a github repository next time with the important files. (Will be more work but better than not fixing the error)
:sweat_smile: I also have no idea how lib_deps works (Should I learn it?)

1 Like

lib_deps is just a list of libraries from either the PlatformIO registry or straight URLs (github, zip files, etc.) which point to libraries you want PlatformIO to compile with your project.

It’s all documented.

https://docs.platformio.org/en/latest/librarymanager/dependencies.html#librarymanager-dependencies

https://docs.platformio.org/en/latest/projectconf/sections/env/options/library/lib_deps.html

E.g.,

lib_deps =
   adafruit/Adafruit_VL6180X@^1.4.4