Undefined reference to `vtable for esphome::my_component::my_component'

Hi,

I’m trying to develop an external component because a need a custom component with actions and triggers.

I started very simple but I immediately get an error message:
undefined reference to `vtable for esphome::my_component::my_component’

This is my source

test.yaml

esphome:
  name: test
  friendly_name: external component test
      
esp32:
  board: mhetesp32minikit
  framework:
    type: arduino

external_components:
  - source:
      type: local
      path: my_components
    components: [ my_component ]

wifi:
    ssid: !secret wifi_ssid
    password: !secret wifi_password
  
# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

my_component:
  id: test
  tx_pin: 13

__init__.py

import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import pins
from esphome.const import (
  CONF_ID,
  CONF_TX_PIN,
)

my_component_ns = cg.esphome_ns.namespace('my_component')
MyComponent = my_component_ns.class_('my_component', cg.Component)

CONFIG_SCHEMA = cv.Schema({
  cv.GenerateID(): cv.declare_id(MyComponent),
  cv.Required(CONF_TX_PIN): pins.gpio_input_pin_schema,
}).extend(cv.COMPONENT_SCHEMA)

async def to_code(config):
  var = cg.new_Pvariable(config[CONF_ID])
  await cg.register_component(var, config)

my_component.h

#pragma once
#include "esphome/core/component.h"
#include "esphome/core/hal.h"
#include "esphome/core/log.h"

namespace esphome {
namespace my_component {

class my_component : public Component {
  public:
    void set_pin_tx(GPIOPin *pin) { pin_tx = pin; }
    void setup() override;
    void loop() override;
  protected:
    GPIOPin *pin_tx;
    void transmitCommand(int cmd);
};

} // namespace my_component
} // namespace esphome

my_component.cpp

#include <my_component.h>

namespace esphome {
namespace my_component {

void my_component::transmitCommand(int CMD) {
  ESP_LOGD("my_component","Command: %d", CMD);
}

} // namespace my_component
} // namespace esphome

I’m not seeing it (as newbie).
What is wrong here?

So I forget to strip setup() and loop() from my code.

Removing setup and loop fixed the error.