I have a very simple MouseTrapCar.ino file, which calls the actual functionality in a C++ class.
#include "CarControl.h"
CarControl control;
void setup()
{
control.Setup();
}
void loop()
{
control.Loop();
}
When I build using a derivative of queezy's cmake-arduino (from a CLion Arduino plugin), I get link errors:
Scanning dependencies of target MouseTrapCar
[ 96%] Building CXX object CMakeFiles/MouseTrapCar.dir/MouseTrapCar_MouseTrapCar.ino.cpp.obj
[100%] Linking CXX executable MouseTrapCar.elf
CMakeFiles/MouseTrapCar.dir/MouseTrapCar_MouseTrapCar.ino.cpp.obj: In function `_GLOBAL__sub_D_control':
/home/fbrier/Projects/MouseTrapCar/MouseTrapCar.ino:8: undefined reference to `CarControl::Setup()'
/home/fbrier/Projects/MouseTrapCar/MouseTrapCar.ino:8: undefined reference to `CarControl::Loop()'
/home/fbrier/Projects/MouseTrapCar/MouseTrapCar.ino:8: undefined reference to `CarControl::CarControl()'
/home/fbrier/Projects/MouseTrapCar/MouseTrapCar.ino:8: undefined reference to `CarControl::~CarControl()'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/MouseTrapCar.dir/build.make:89: MouseTrapCar.elf] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/MouseTrapCar.dir/all] Error 2
gmake: *** [Makefile:84: all] Error 2
I am new to Arduino, but an experienced C++ developer. I heard the Arduino IDE was limiting once your app got more complex, so it seemed a good idea to just start with CLion and CMake. The errors could be a name mangling issue, where the .ino file is not resolving references with the class in the .h/.cpp. However, googling did not turn up users with similar problems. Maybe a CMake file error? I would be glad to post all the code. I was holding off pushing these latest changes to GitHub until it successfully built. Thank you.