user1499: I am experimenting with creating my own Arduino libraries. Unfortunately, while the program compiles, the end result does not work.
For purposes of experimentation, I have broken down the library in two parts. One that will handle blinking by controlling the LED_BUILDIN pin and one that will talk to the serial input.
Thus two .h and two .cpp files. Plus there is another file for the configuration that handles preprocessor directives that the library reads.
This is the code:
FILE 1
//header_config.h
#ifndef MY_CONFIGURATION
#define MY_CONFIGURATION

#include <Arduino.h>

#define SERIAL_DEBUG
#define LED_BLINK

#include <led_functions.h>
#include <serial_functions.h>

void my_setup()
{
  my_setup_led();
}


void my_loop()
{
    led_blinker();
    serial_transmit("Hello");
}

#endif

FILE 2
//led_functions.h
#ifndef MY_LED_LIBRARY
#define MY_LED_LIBRARY
   
  #include <Arduino.h>
  #include "header_config.h"
  #include "serial_functions.h"


  extern void led_blinker();
  extern void my_setup_led();

#endif

FILE 3
//led_functions.cpp
void led_blinker()
{
  #ifdef LED_BLINK
  digitalWrite(LED_BUILTIN, HIGH);
  serial_transmit("LED ON");
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  serial_transmit("LED OFF");
  delay(1000);
  #endif
}

void my_setup_led()
{
#ifdef LED_BLINK
pinMode(LED_BUILTIN, OUTPUT);
#endif
}

FILE 4
//serial_functions.h
#ifndef MY_SERIAL_LIBRARY
#define MY_SERIAL_LIBRARY


  #include <Arduino.h>
  #include "header_config.h"

  #ifdef SERIAL_DEBUG
  #include <SoftwareSerial.h>
  #define rxPin 2
  #define txPin 3
  SoftwareSerial mySerial(rxPin, txPin);
  #endif

  extern void serial_transmit(char*);

#endif

FILE 5
//serial_functions.cpp
void serial_transmit(char *str)
{
  #ifdef SERIAL_DEBUG
  //mySerial.begin(9600);
  //mySerial.println(str);
  //mySerial.end();
  Serial.begin(9600);
  Serial.println(str);
  Serial.end();
  #endif
}

Please note that while the serial code creates a SoftwareSerial object (in serial_functions.h), I do not use that (in serial_functions.cpp) and instead I make use of hardware Serial. The reason is debugging, so that I can see communication on the PC. I left the SoftwareSerial object inside, because that is what I ultimately want.
Finally, outside the library, in it's separate folder, is the .ino file that makes use of this library.
#include <header_config.h>
#include <led_functions.h>
#include <serial_functions.h>

void setup()
{
  my_setup();
}

void loop()
{
  my_loop();
}

As I said, the program compiles fine, but it does not work in the real world. Neither the blinking, nor the serial communication.

user37622: Your cpp files don't include the header_config.h file, so they don't have SERIAL_DEBUG and LED_BLINK defined.
The content of included file replaces the include directive so if you now include header_config.h into both cpp, there will be 3 functions named my_setup() and 3 functions named my_loop() and the linker will complain. So you can't put functions definitions into an include file. And for the same reason you can't have variable definitions in .h file so the SoftwareSerial instance will cause problems too if used.

1499: <p>I am experimenting with creating my own Arduino libraries. Unfortunately, while the program compiles, the end result does not work.</p>
<p>For purposes of experimentation, I have broken down the library in two parts. One that will handle blinking by controlling the <code>LED_BUILDIN</code> pin and one that will talk to the serial input.</p>
<p>Thus two <code>.h</code> and two <code>.cpp</code> files. Plus there is another file for the configuration that handles preprocessor directives that the library reads.</p>
<p>This is the code:</p>
<p>FILE 1</p>
<pre><code>//header_config.h
#ifndef MY_CONFIGURATION
#define MY_CONFIGURATION

#include &lt;Arduino.h&gt;

#define SERIAL_DEBUG
#define LED_BLINK

#include &lt;led_functions.h&gt;
#include &lt;serial_functions.h&gt;

void my_setup()
{
  my_setup_led();
}


void my_loop()
{
    led_blinker();
    serial_transmit(&quot;Hello&quot;);
}

#endif
</code></pre>
<p>FILE 2</p>
<pre><code>//led_functions.h
#ifndef MY_LED_LIBRARY
#define MY_LED_LIBRARY
   
  #include &lt;Arduino.h&gt;
  #include &quot;header_config.h&quot;
  #include &quot;serial_functions.h&quot;


  extern void led_blinker();
  extern void my_setup_led();

#endif
</code></pre>
<p>FILE 3</p>
<pre><code>//led_functions.cpp
void led_blinker()
{
  #ifdef LED_BLINK
  digitalWrite(LED_BUILTIN, HIGH);
  serial_transmit(&quot;LED ON&quot;);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  serial_transmit(&quot;LED OFF&quot;);
  delay(1000);
  #endif
}

void my_setup_led()
{
#ifdef LED_BLINK
pinMode(LED_BUILTIN, OUTPUT);
#endif
}
</code></pre>
<p>FILE 4</p>
<pre><code>//serial_functions.h
#ifndef MY_SERIAL_LIBRARY
#define MY_SERIAL_LIBRARY


  #include &lt;Arduino.h&gt;
  #include &quot;header_config.h&quot;

  #ifdef SERIAL_DEBUG
  #include &lt;SoftwareSerial.h&gt;
  #define rxPin 2
  #define txPin 3
  SoftwareSerial mySerial(rxPin, txPin);
  #endif

  extern void serial_transmit(char*);

#endif
</code></pre>
<p>FILE 5</p>
<pre><code>//serial_functions.cpp
void serial_transmit(char *str)
{
  #ifdef SERIAL_DEBUG
  //mySerial.begin(9600);
  //mySerial.println(str);
  //mySerial.end();
  Serial.begin(9600);
  Serial.println(str);
  Serial.end();
  #endif
}
</code></pre>
<p>Please note that while the serial code creates a <code>SoftwareSerial</code> object (in <code>serial_functions.h</code>), I do not use that (in <code>serial_functions.cpp</code>) and instead I make use of hardware Serial. The reason is debugging, so that I can see communication on the PC. I left the <code>SoftwareSerial</code> object inside, because that is what I ultimately want.</p>
<p>Finally, outside the library, in it's separate folder, is the <code>.ino</code> file that makes use of this library.</p>
<pre><code>#include &lt;header_config.h&gt;
#include &lt;led_functions.h&gt;
#include &lt;serial_functions.h&gt;

void setup()
{
  my_setup();
}

void loop()
{
  my_loop();
}
</code></pre>
<p>As I said, the program compiles fine, but it does not work in the real world. Neither the blinking, nor the serial communication.</p>
 37622: <p>Your cpp files don't include the header_config.h file, so they don't have SERIAL_DEBUG and LED_BLINK defined.</p>
<p>The content of included file replaces the include directive so if you now include header_config.h into both cpp, there will be 3 functions named my_setup() and 3 functions named my_loop() and the linker will complain. So you can't put functions definitions into an include file. And for the same reason you can't have variable definitions in .h file so the SoftwareSerial instance will cause problems too if used.</p>
