0 votes 0 answers 21 views Arduino IDE on LINUX system, how to use the #include directive to get files specific from a NAS

I tried this on another forum without results so I will try here. I have spent many hours on several occasions with the Arduino IDE (Integrated Development Environment) trying to include files from a specified directory on a NAS (Network Area Storage) unit. I found a lot of answers mostly for Windows and a few for Linux but none of them worked. I am using Linux 4.10.0-38-generic x86_6 with Linux Mint 18.3 Cinnamon 64-bit. I can not get the Arduino IDE 1.8.13 or any previous IDEs I have tried to pick up files from a specified directory located on a NAS using the #include directive.

The folder with the IDE files etc works just fine on the NAS. Currently I am including library files in the folder as well. I include them with this: #include "#include "LiquidCrystal_I2C.h" Since I changed the CAN library I included it: #include "mcp_can.h" in the same directory as the .ino file. The path to the file “Cal_Room_.ino” is “smb://server20.local/videos/HA_CAN/Cal_Room_/Cal_Room_.ino”. Since I use the “.h” files in other programs I would like to put them in a common directory such as “ smb://server20.local/videos/HA_CAN/Core/(the files)”. Can I accomplish this using Linux with a NAS? There are two reasons, common code can be shared between programs and as the library files change I do not have to go find one that will work, the original is saved with the program. I would like to know the path to include a specific file such as: #inculde “smb://server20.local/videos/HA_CAN/Core/XXX.h” can anybody help? Thanks

I think you have to make the IDE portable to deal with the remote folder issue, but I just read that once.
This was the recommended page for that issue:
Slow compile times with Windows 10 build 19042 - Using Arduino / Installation & Troubleshooting - Arduino Forum

I have no idea if it will help you, but it can't hurt to try.

Thanks for the information, It is not what exactly what I need but it did give me some ideas. I installed the IDE as normal and have been using it for over a year. The problem came with a new project with several modules (programs) that will use the same functions, definitions, and equates. If I place them in the NAS folder with the .ino file the IDE is ok with that. I want to place them in another folder it will not find them. It finds the files in the normal library no problem. Currently I edit them in the sub folder and copy them into the folder with the .ino file. That works but can get confusing, I currently have 5 modules I am working with. It is a custom CAN network.

What is the exact symptom? If there is an associated error or warning message, please post the full and exact text of it.

It tells me it cannot find it or symbol is undefined depending on what it is. If I put the .h file in the same folder as the .ino file it works just fine. I have it as #include "file.h" the file is labeled file.h.

I asked for the full and exact text.

Give me some time I have to move some files and try to remember how I tried. I cannot get to the machine until tomorrow.

As far as I know, the problem is that the IDE does not compile the .CPP files. It willhappily include a .H files that you point it at.

I'm not 100% sure, but the directories where it will look for .CPP files are basically predefined (Arduino installation libraries, sketchbook libraries directory and sketch src directory).

There was a similar question not too long ago (if not mistaken) and the solution (again, if not mistaken) was to put a symlink in one of those directories.

An alternative is not to use .CPP files and place the code in .H files; not 100% satisfying in my opinion.

What sterretje said applies to #include directives for any files outside the standard libraries folders; nothing specific to NAS. You can do the #include, but the source files in that location will not be compiled as they would be with a library installed to one of the standard locations. So you essentially just get a copy/paste of the contents of the #included file into the sketch.

Here you go: I used the same files and only changed the one #include. I also included screen shots of the two directories. Sorry I crop them but they changed when uploaded. When it is in the same directory as the .INO file all goes OK. I then tried placing it in another directory, and as I worked down the include statement I kept getting the same errors. I posted several of those attempts.
Origional header at top of file
// Note the "" forces it to look in the sketch folder first for the library. the LCD libraries have problems.
#include "Wire.h" // This allows us to communicate via I2C
#include "LiquidCrystal_I2C.h" // This library works and talks to the PCF8574, others do not
#include "mcp_can.h" // Use the local library
#include <SPI.h> // Allows communication to the MPC2515
#include "Home_Can_Address.h"
#include "Home_Can_Functions.h"
#define I_Am Cal_Room
Note: Only the “Home_Can_Address.h” path was changed, nothing else. It tried it with both “” and <> same results. I did not bother posting the code as there is a lot of it, well over 1000 lines. The only change I made was in the one line and it is posted below with the error given. This is just a few of the attempts but the error is consistent, it cannot find the file.

Sketch uses 12690 bytes (39%) of program storage space. Maximum is 32256 bytes.
Global variables use 930 bytes (45%) of dynamic memory, leaving 1118 bytes for local variables. Maximum is 2048 bytes.
\
#include "smb://server20.local/videos/HA_CAN/Home_Can_Address.h"
Cal_Room_:7:10: fatal error: smb://server20.local/videos/HA_CAN/Home_Can_Address.h: No such file or directory
#include "smb://server20.local/videos/HA_CAN/Home_Can_Address.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
smb://server20.local/videos/HA_CAN/Home_Can_Address.h: No such file or directory
\
#include "//server20.local/videos/HA_CAN/Home_Can_Address.h"
Arduino: 1.8.13 (Linux), Board: "Arduino Uno"
Cal_Room_:7:10: fatal error: //server20.local/videos/HA_CAN/Home_Can_Address.h: No such file or directory
#include "//server20.local/videos/HA_CAN/Home_Can_Address.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
//server20.local/videos/HA_CAN/Home_Can_Address.h: No such file or directory
\
#include "videos/HA_CAN/Home_Can_Address.h"
Cal_Room_:7:10: fatal error: videos/HA_CAN/Home_Can_Address.h: No such file or directory
#include "videos/HA_CAN/Home_Can_Address.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
videos/HA_CAN/Home_Can_Address.h: No such file or directory
\
#include "HA_CAN/Home_Can_Address.h"
Cal_Room_:7:10: fatal error: HA_CAN/Home_Can_Address.h: No such file or directory
#include "HA_CAN/Home_Can_Address.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
HA_CAN/Home_Can_Address.h: No such file or directory
\
#include "/Home_Can_Address.h"
Cal_Room_:7:10: fatal error: /Home_Can_Address.h: No such file or directory
#include "/Home_Can_Address.h"
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
/Home_Can_Address.h: No such file or directory
\
#include <Home_Can_Address.h>"
Cal_Room_:7:10: fatal error: Home_Can_Address.h: No such file or directory
#include <Home_Can_Address.h>"
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Home_Can_Address.h: No such file or directory
\
#include "Home_Can_Address.h"
Sketch uses 12690 bytes (39%) of program storage space. Maximum is 32256 bytes.
Global variables use 930 bytes (45%) of dynamic memory, leaving 1118 bytes for local variables. Maximum is 2048 bytes.


in0 & sterretje: If the .CPP files and .h files are in the same folder as the sketch they compile just fine. It will also add any .ino files in that directory in alpha order. To my knowledge the my Linux system does not support symlink to any non local drives. I have tried many times without any luck.

It doesn't look like this code matches to the error messages you posted below.

Surely you can reproduce the issue with a sketch of only a few lines.

Please try again, but this time provide a complete minimal sketch and the full output from compiling that sketch.

Please be sure to post your code and output in accordance with the forum rules:
https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#posting-code-and-common-code-problemsposting-code-and-common-code-problems-18

I did another sketch, about as simple as it can get. I included the wire lib just to show it is looking in the arduino library area. When I run it from my home disk and add the full path it works, that line was commented out. When I run the same thing from the NAS I still have the same problem. Here is the Code and error messages.

#include "Wire.h" // This allows us to communicate via I2C
//include "/home/gil/Desktop/Blink_Blink/Blank/Home_Can_Address.h"
#include "smb://server20.local/videos/Blink_Blink/Blank/Home_Can_Address.h"
#define I_Am Cal_Room

void setup() { }
void loop() { }

The error message:
Blinik_Blink:3:10: fatal error: smb://server20.local/videos/Blink_Blink/Blank/Home_Can_Address.h: No such file or directory
#include "smb://server20.local/videos/Blink_Blink/Blank/Home_Can_Address.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
smb://server20.local/videos/Blink_Blink/Blank/Home_Can_Address.h: No such file or directory

I added verbose.

Nice! There's no chance for confusion now.
This is a different issue from the one sterretje mentioned where the files at the absolute #include path are not compiled. With that issue, you do not get a "No such file or directory" error for the #included file.

It looks like there is an alternative syntax like //server20.local/videos/Blink_Blink/Blank/Home_Can_Address.h, so you can give that a try.

But I think the best approach would be to mount the share. That will get you to the point of being able to #include header files. You would still need to put the files in a standard library installation if you want source files to be compiled.

You must use the "" syntax if the file is not in a standard library installation.

I sure would like to mount the share, but other then clicking on the GUI I do not have a clue as to how. The terminal commands for that are very confusing. I tried your suggestion again but no luck, same error. When using the save as in the IDE it shows the path as "videos on server20.local/Blink_Blink/Blank/Home_Can_Address.h", it has the spaces, I tried with and without spaces, I used "_" as a substitute, no different. I tried your suggestion and then added slashes on the front, // and / but same error. At least it is consistent. With the GUI unless I look in the address bar I have no idea if I am on the NAS or home drive, it all looks and behaves the same. I simply click on the program name (local or NAS) and the IDE launches and loads the program.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.