On Ubuntu 20.04, I have I upgraded to ide 2.0 and located it in /opt.
I have a sketch that worked with 1.8, and it includes a header file located in a directory in the same folder as the .ino file. #include "./CAN_Library-master/CAN.h"
The build fails and the IDE mouse-hover note is this:
OK, that makes sense. I removed the ./ and it has the same build errors.
It seems to me that it is actually is not failing to find the #include file, but complaining about undefined reference to:
undefined reference to `CAN_SAM3X::begin(unsigned long, unsigned char)'
and that is in another local header file included in CAN.h #include "CAN_SAM3X.h"
which doesn't cause an error about missing the file, but it can't seem to see the functions inside CAN_SAM3X.h
Build errors:
> /tmp/arduino-sketch-D9CE203C6CF9257E8541060AFFFC1CBA/sketch/can_pedal_sender_01.ino.cpp.o: In function `CAN_SAM3X::begin(unsigned long)':
> /home/kalee/shopfiles2/all_files/sketchbook/EV/can_pedal_sender_01/CAN_Library-master/CAN_SAM3X.h:165: undefined reference to `CAN_SAM3X::begin(unsigned long, unsigned char)'
> /tmp/arduino-sketch-D9CE203C6CF9257E8541060AFFFC1CBA/sketch/can_pedal_sender_01.ino.cpp.o: In function `setup':
> /home/kalee/shopfiles2/all_files/sketchbook/EV/can_pedal_sender_01/can_pedal_sender_01.ino:46: undefined reference to `CAN'
> /home/kalee/shopfiles2/all_files/sketchbook/EV/can_pedal_sender_01/can_pedal_sender_01.ino:46: undefined reference to `CAN_SAM3X::write(CAN_Frame const&)'
> /tmp/arduino-sketch-D9CE203C6CF9257E8541060AFFFC1CBA/sketch/can_pedal_sender_01.ino.cpp.o: In function `loop':
> /home/kalee/shopfiles2/all_files/sketchbook/EV/can_pedal_sender_01/can_pedal_sender_01.ino:59: undefined reference to `CAN_SAM3X::write(CAN_Frame const&)'
> /home/kalee/shopfiles2/all_files/sketchbook/EV/can_pedal_sender_01/can_pedal_sender_01.ino:66: undefined reference to `CAN'
> collect2: error: ld returned 1 exit status
>
> exit status 1
>
> Compilation error: exit status 1
Seems like that the library is not included in a normal way.
Is the CAN library in the Library Manager ? Or can you install it as a *.zip file from the Arduino IDE ?
This is a library that has been modified and I put in a local folder so it would stay with the project even when moved to another PC. So far this technique has worked for me, but the ide-2.0 seems to handle the files differently.
OK, I figured out how to make it work. All the library files need to be at the same level as the main .ino file. I moved all the .h and .ccp files from the sub-folder, and they magically appeared as tabs in the project!
Builds fine now, just as before.
If you prefer to put them in a sub-folder, you can use the src subfolder of the sketch folder. This folder is given special treatment in that the source files under it are compiled recursively.
You must use the relative path from the root of the sketch folder in the #include directives in your sketch.
For example, if you had a sketch with this structure: