I'm trying to get a rather large sketch working with a teensy LC. I'd like to break it into headers and C files, but the multi-file sketch fails to compile. When I put everything into a single, monolithic sketch, it runs fine. I've #included the h files where they are needed, using single quotes, and have confirmed that my h files are in the same folder as my sketch. Is there an additional step to go through specific to teensy? I've managed to do this tons of times using a standard arduino.
Here is a basic sketch:
This is the main sketch file:
#include "tst.h"
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
doNothing();
}
This is tst.h
void doNothing();
This is tst.c
#include "tst.h"
void doNothing()
{
int i = 0;
}
I get the error "undefined reference to doNothing() in function loop"
".c"file instead of".cpp"? – J. Piquard Dec 24 '16 at 13:54"test.c"file to"test.cpp". This is the default extension expected by the C++ compiler used by Arduino IDE. – J. Piquard Dec 24 '16 at 15:51"test.c"and the"test.h"appear on the top, the"test.c"seems to be compiled"mylib.c.o"and thedoNothingis present inside. But the error is alwaysUsingCpp.ino:14: undefined reference to 'doNothing()'. – J. Piquard Dec 24 '16 at 16:35