CLionArduinoPlugin icon indicating copy to clipboard operation
CLionArduinoPlugin copied to clipboard

I'm unable to build a multiple file project

Open ghost opened this issue 9 years ago • 1 comments

Hi, I'm working on a UNO project in CLion with multiple .cpp & .h files, and am unable to figure out how to get them to link. Please Help.

Output: [100%] Linking CXX executable MultipleFileTest.elf CMakeFiles/MultipleFileTest.dir/MultipleFileTest_MultipleFileTest.ino.cpp.obj: In function loop': /home/keri/ClionProjects/MultipleFileTest/MultipleFileTest.ino:9: undefined reference toTestMenu()'

ghost avatar May 30 '16 14:05 ghost

Hi, the arduino compile process requires your libraries (which adding multiple .cpp & .h files to one .ino file is) to be in a folder with the same name inside your project. E.g. PATH_TO_PROJECT/use_lib.ino: #include <Arduino.h> #include "MyLib/MyLib.h" ...

PATH_TO_PROJECT/MyLib/MyLib.h: class MyClass { void doSth(); };

PATH_TO_PROJECT/MyLib/MyLib.cpp: void MyClass::doSth() { ... }

Then the generate_arduino_firmware function will link it correctly to your .ino.

daddonpa avatar Jul 16 '16 09:07 daddonpa