Include libraries properly

Hi @maxgerhardt and thank you for your support!!
It seems that my problem solved as soon as I renamed the LAN.c to LAN.cpp.
I know that arduino IDE accepts both c and c++ libraries but for the current project I use VScode and Platformio, so in general I have to use only c++ libraries (unfortunately I do not have the error logging before renaming)?

After renaming the file from .c to .cpp, two separate error popped up

Building in release mode
Compiling .pio\build\mkrwifi1010\src\main.cpp.o
Linking .pio\build\mkrwifi1010\firmware.elf
.pio\build\mkrwifi1010\src\main.cpp.o: In function `setup':
main.cpp:(.text.setup+0x18): undefined reference to `ethernet_init(unsigned char)'
main.cpp:(.text.setup+0x1e): undefined reference to `DHCP_config(unsigned char*)'
main.cpp:(.text.setup+0x22): undefined reference to `hardware_present()'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\mkrwifi1010\firmware.elf] Error 1

and this error:

Building in release mode
Compiling .pio\build\mkrwifi1010\libe6c\Ethernet_lib\LAN.cpp.o
Archiving .pio\build\mkrwifi1010\libe6c\libEthernet_lib.a
arm-none-eabi-ar: unable to rename '.pio\build\mkrwifi1010\libe6c\libEthernet_lib.a'; reason: File exists
*** [.pio\build\mkrwifi1010\libe6c\libEthernet_lib.a] Error 1

I solved these error by removing the project folder from the workspace and adding it back again… This is something like a bug or what?

These are the files after error fixing

Main.cpp (main .ino)

#include <SPI.h>
#include <Ethernet.h>
#include <Arduino.h>
#include "config.h"
#include <LAN.h>

uint8_t mac[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05}; // MAC address for ethernet shield. This is a random address and you can change it
byte CS_PIN = 5;

void setup()
{

  Serial.begin(115200);
  delay(1000); // give some time for the serial monitor to open

  ethernet_init(CS_PIN); // Configure the CS pin
  DHCP_config(mac);
  hardware_present();
  connection_link();

}

void loop()
{

  Serial.print("Hi");
  delay(1000);
}

Lan.cpp

#include "LAN.h"

//Configure the CS pin
void ethernet_init(byte CS_PIN)
{
    Ethernet.init(CS_PIN); // Configure the CS pin
}

void DHCP_config(uint8_t *mac)
{
    bool DHCP = Ethernet.begin(mac); // Returns 0 if the DHCP configuration failed, and 1 if it succeeded

    if (!DHCP)
    {
        Serial.println("DHCP configuration failed");
    }
    else if (DHCP)
    {
        Serial.println("DHCP configuration succeed");
    }
}

//Check for Ethernet hardware present
void hardware_present()
{
    if (Ethernet.hardwareStatus() == EthernetNoHardware)
    {
        Serial.println("Ethernet shield was not found. Connect ethernet shield");
        while (true)
        {
            delay(1); // do nothing, no point running without Ethernet hardware
        }
    }
    else
    {
        Serial.print("Ethernet shield found: ");
        switch (Ethernet.hardwareStatus())
        {
        case 1:
            Serial.println("EthernetW5100");
            break;
        case 2:
            Serial.println("EthernetW5200");
            break;
        case 3:
            Serial.println("EthernetW5500");
            break;
        default:
            break;
        }
    }
}

//Check if the ethernet cable is conencted
void connection_link()
{
    while (Ethernet.linkStatus() == LinkOFF)
    {
        Serial.println("Ethernet cable is not connected.");
        delay(500);
    }

    // give the Ethernet shield a second to initialize:
    delay(1000);
    Serial.println("connecting...");
}

LAN.h

#ifndef LAN_H
#define LAN_H

 #include <Arduino.h>
 #include <SPI.h>
 #include <Ethernet.h>


void ethernet_init(byte CS_PIN);
void DHCP_config(uint8_t *mac);
void hardware_present(void);
void connection_link(void);

#endif