Racking my brain for the past few days over what I believe is a linker issue. I have a simple .h and .cpp file defined but when I try to compile the .ino program I receive an undefined reference error. I am using VS Code with CLI 1.7.1. Targeting a Boron on 1.4.0. Any guidance would greatly be appreciated!
Exact error:
undefined reference to `RTC_DS3231::begin()'
collect2: error: ld returned 1 exit status
Here is the code below:
rtc.ino
SerialLogHandler logHandler(ALL_LEVEL);
SYSTEM_MODE(SEMI_AUTOMATIC);
#include "../lib/Adafruit-RTClib/RTClib.h"
RTC_DS3231 rtc;
void setup() {
Serial.begin(115200); //open serial console
delay(10000); //10 seconds
rtc.begin();
}
void loop() {
//Do nothing right now
}
RTClib.h
#ifndef RTCLIB_H
#define RTCLIB_H
class RTC_DS3231 {
public:
bool begin();
};
#endif // RTCLIB_H
RTCLib.cpp
#include <Wire.h>
#include "RTClib.h"
boolean RTC_DS3231::begin() {
Wire.begin();
return true;
}