francoiscampbell / CLionArduinoPlugin

A plugin for CLion that enables arduino-cmake integration.
155 stars 41 forks source link

I'm unable to build a multiple file project #20

Open ghost opened 8 years ago

ghost commented 8 years ago

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()'

daddonpa commented 8 years ago

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.