[SOLVED] Undefined reference in custom component

I’m trying to make a WiFi enabled egg-cooker. I have a working Arduino sketch and am now trying to port it to ESPHome so that it can interface with Home Assistant. Here’s a link to the code: Smart-Egg-Cooker/eggslice at feature-esphome · Amanoo/Smart-Egg-Cooker · GitHub

In this folder, run these commands:

python3 -m venv venv 
source venv/bin/activate
pip3 install esphome
pip3 install tornado esptool
esphome run eggcooker.yaml

This will compile the whole thing. However, it will eventually throw an error:

/home/marco/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/eggcooker/src/main.cpp.o:(.literal._ZNSt17_Function_handlerIFSt6vectorIPN7esphome9ComponentESaIS3_EEvEZ5setupvEUlvE_E9_M_invokeERKSt9_Any_data+0x8): undefined reference to `EggCooker::EggCooker(esphome::sensor::Sensor*, esphome::text_sensor::TextSensor*)'
/home/marco/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/eggcooker/src/main.cpp.o: in function `std::_Function_handler<std::vector<esphome::Component*, std::allocator<esphome::Component*> > (), setup()::{lambda()#1}>::_M_invoke(std::_Any_data const&)':
/home/marco/Desktop/Smart-Egg-Cooker-feature-esphome/eggslice/.esphome/build/eggcooker/eggcooker.yaml:53: undefined reference to `EggCooker::EggCooker(esphome::sensor::Sensor*, esphome::text_sensor::TextSensor*)'

In my yaml file, my custom component is defined as follows:

custom_component:
    - lambda: |-
        auto my_custom = new EggCooker(id(secs),id(state));
        App.register_component(my_custom);
        return {my_custom};

This should create the entire thing. Secs is a sensor with device_class duration, and state is a text_sensor, both described in the yaml. These are passed to the EggCooker constructor. The EggCooker is defined in the eggslice.h file and accompanying cpp.

EggCooker::EggCooker(Sensor* secs, TextSensor* state)  : secs_(secs), state_(state) {} 

This should just use the two sensors and save their pointers. Seems like it’s the type of constructor the yaml should want. Yet, it complains. I’ve tried to toy around with namespaces and with adding esphome::sensor:: and esphome::text_sensor:: in front of everywhere, but it just won’t stop complaining about this. I’m not sure what I’m doing wrong.

EDIT: seems like I needed to include the cpp file as well in my yaml, I only included the .h file. Still some errors but I think I’m making progress.