I just migrated from Windows to Linux (Fedora 22); the Arduino Blink program is working.
I am having trouble with using library in Arduino; maybe I have something setup wrong.
I created a small library but Arduino IDE is not finding it.
The Arduino directory contains:
/home/wolfv/Arduino/test_sketch/test_sketch.ino
/home/wolfv/Arduino/libraries/test_lib/test_file.h
The instruction on https://www.arduino.cc/en/guide/libraries says to "Make sure the new library appears in the Sketch->Import Library menu item".
I am running Arduino 1.6.5 and it does not have a "Sketch->Import Library".
Although, it does have a "Sketch->Include Library", but the test_lib library is not in there.
This is the test_sketch.ino:
#include <test_file.h>
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
I restarted the Arduino IDE, click "Verify", and this compile message comes up:
Usually, if the include file is named test_file.h, the code file is test_file.cpp and its library directory is test_file. That would imply that the correct library path should be:
econjack:
Usually, if the include file is named test_file.h, the code file is test_file.cpp and its library directory is test_file. That would imply that the correct library path should be:
I tried the include with quotes and still got the same error.
However, it does compile after moving the test_file.h into the sketch directory.
So the #include "test_file.h" works when the file is in the sketch directory, but not when the file is in the libraries directory.
And #include <test_file.h> doesn't work at all.
Does Arduino on Linux require some special setting to find libraries?
My Arduino IDE 1.6.5 does not have a "Sketch->Import Library", is that normal?
wolfv:
Does Arduino on Linux require some special setting to find libraries?
My Arduino IDE 1.6.5 does not have a "Sketch->Import Library", is that normal?
Normally there is nothing special that has to be done.
The gcc compiler for the past several years treats #include <file.h> and #include "file.h" pretty much the same.
They both will end up looking on the include path so that is not the issue here.
In order for the IDE to "see" and use a library all you have to do is create the library directory for in the proper place.
The name of the header file or any other source code module in the library directory can be anything that you want.
The key is the location of the library directory.
Once it is in the proper place, the name of the library directory will show up in [Sketch]->[Include Library] list.
I just tried it on 1.6.5 on linux mint and it works just fine.
I created a "foo" directory under my {sketchbook}/libraries directory and added a bar.h to that file.
The sketch includes bar.h and it is found just fine.
The "foo" library shows up in the sketch->include library list even though the header is bar.h and the sketch is including bar.h
First thing I'd do is verify that you are using the correct sketchbook directory.
Look in [File]->Preferences to see the sketchbook location.
Under that you will need a "libraries" directory and then under that, the directory for your library.
Another thing that I'd check is to run the build in verbose mode turned on, that will tell you what directories are being included.
That will tell you if the IDE is seeing the library header file in your library directory.
If neither of those show anything, what could be the issue is the teensy extension. I didn't try it with the Teensy extension.
I know that Paul has some pretty strong feelings as to how the library include path searching should work and often has put in patches to alter the way the IDE searches for header files. He and I have several discussions over this and some of the things has done have broken my graphic library.
It was all attempt to try to help eliminate library header collisions. In reality the changes that were done in the past that broke my library didn't help and actually had the potential to silently and confusingly break things that used to work - like my graphic library.
It is possible that the latest 1.6.5 header searching is not working correctly in the Teensy environment when there are no other source code modules.
Perhaps try it with a non teensy board and see if that changes anything.
Other than that, you might try installing another 1.6.5 IDE and try it without the teensy extension.
You don't need to uninstall your existing setup, just extract the IDE image somewhere else and run it from there.
Wow bill, thanks for the detailed information. I think you exposed the problem.
My Preferences dialog box does not display a "sketchbook location" or "libraries" directory.
My /home/wolfv/.arduino15/preferences.txt file has the expected sketchbook location:
sketchbook.path=/home/wolfv/Arduino
But no "libraries" or "test_file" directory is mentioned. I searched the preferences.txt file:
Pattern not found: lib
Pattern not found: test_file
Verbose output has been on, and it doesn't mention any directories.
Could I manually add the "libraries" directory and "my library" directory to the preferences.txt file?
What would be the correct syntax for that?
bperrybap:
Perhaps try it with a non teensy board and see if that changes anything.
Other than that, you might try installing another 1.6.5 IDE and try it without the teensy extension.
You don't need to uninstall your existing setup, just extract the IDE image somewhere else and run it from there.
--- bill
Unfortunately I can't do that because I don't have a non-teensy board (the instructions for installing Arduino on Linux say to "Plug In your arduino" Arduino Playground - HomePage ).
wolfv:
Wow bill, thanks for the detailed information. I think you exposed the problem.
My Preferences dialog box does not display a "sketchbook location" or "libraries" directory.
I have never seen a version of the IDE that does not show it and since the code is all JAVA all the IDEs should be the same.
The IDE I have is the linux 1.6.5 IDE which should be the same one you are using.
It should be right at the top when you:
Click
[File]->Preferences
or Press:
,
(control comma)
That should bring up a dialog box and it will be in a text box right at the top of that dialog box.
It will say: "Sketchbook location" right above the text box.
Could I manually add the "libraries" directory and "my library" directory to the preferences.txt file?
What would be the correct syntax for that?
cd to your sketch book directory and make the "libraries" directory under your sketchbook directory then put your library directory under that.
wolfv:
Unfortunately I can't do that because I don't have a non-teensy board (the instructions for installing Arduino on Linux say to "Plug In your arduino" Arduino Playground - HomePage ).
Yes you can.
You never need to have any Arduino hardware in order to bring up the IDE and build a sketch. The hardware is only needed to upload the built sketch to the h/w.
So you can always select any board type you want and build the sketch.
I stand corrected, my Preferences dialog box does display my "Sketchbook location" just as you described.
I installed a 1.6.5 IDE in another location without the teensy extension. And still got the same error.
Details of testing the non-teensy Ardunio IDE follow.
$ cd /home/wolfv/Downloads
$ sudo tar -xf arduino-1.6.5-linux64.tar.xz -C /usr/local/bin
$ /usr/local/bin/arduino-1.6.5/arduino
Non-teensy Ardunio IDE > [Tools] > [Board] > Adruino Nano
Restart the non-teensy Ardunio IDE, and click Verify. Get this compile error:
This is in my sketchbook directory: /home/wolfv/Documents/Arduino/test_sketch/test_sketch.ino
It is listed in [File] > [Preferences] > Sketchbook location
It is also listed in /home/wolfv/.arduino15/preferences.txt: sketchbook.path=/home/wolfv/Arduino
This is my library directory: /home/wolfv/Documents/Arduino/libraries/test_file/test_file.h
It is not listed in [Sketch]->[Include Library] list
It is not listed in my preferences.txt file.[/code]
Correction:
I compiled the wrong file and posted the results in the preceding post a few hours ago.
Both Arduino 1.6.5 IDEs, with and without teensy extension, get the same "No such file or directory" error.
I have corrected the preceding post. I apologize for causing confusion.
I found the problem.
The Sketchbook Location was /home/wolfv/Arduino (I did not notice the missing "Documents").
Now I change the Sketchbook Location to /home/wolfv/Documents/Arduino and everything compiles nice.
Thank you for your patients bperrybap. Sketchbook Location was one of the first things you mentioned.
"Documents" wasn't really "missing" by default in the Arduino sketchbook path. "Documents" is just a goofy Microsoft Windows naming thing that has unfortunately been adopted by some Linux distributions.
So what happened between post #1 (and few other posts) where you told us the paths you were using were here:
The Arduino directory contains:
/home/wolfv/Arduino/test_sketch/test_sketch.ino
/home/wolfv/Arduino/libraries/test_lib/test_file.h
And post #14 where you said the paths were here:
This is in my sketchbook directory: /home/wolfv/Documents/Arduino/test_sketch/test_sketch.ino
This is my library directory: /home/wolfv/Documents/Arduino/libraries/test_file/test_file.h
BTW, I always create a "sketches" directory under the arduino {sketchbook} directory to keep all the sketches in a clean subdirectory away from the hardware cores and libraries so you end up with
bperrybap:
I always create a "sketches" directory under the arduino {sketchbook} directory to keep all the sketches in a clean subdirectory away from the hardware cores and libraries so you end up with
hardware
libraries
sketches
under the {sketchbook} directory.
--- bill
What is the "hardware" directory for? (my Arduino install has a /usr/local/bin/arduino-1.6.5/hardware/ )
The hardware directory under your {sketchbook} directory is the recommended place for 3rd party add-on cores.
Paul chose not to install his Teensy cores there but other cores like tiny and 1284 cores will install there (if you add them)
But what about the directory location discrepancies for your sketchbook directory in your post #1 vs post #14?
Sounds like you mislead us in post #1 by providing incorrect information.