I am new to Arduino. I am having a problem verifying sketches. The problem seems to be with the libraries. For example,
I have placed RTClib.h and RTC.cpp into an RTClib folder and placed that into the libraries folder. When I use a #include RTClib.h in my sketch, it is not highlighted like the <wire.h> include is highlighted.
When I try to verify, the software tells me that it can't find RTClib.h. Why can't it find it? It shows up in the Import Library pull down menu and it is entered into my sketch. But that's it!
The same holds for my DS1307RTC library and the Time library. I am using Arduino 1.0 on my Mac and Arduino 23 on my PC.
The library folder on the Mac is in the same folder as the Arduino app.
It seems to be true for any library I enter.
Help!
#include problem
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88097
- Joined: Sat Feb 07, 2009 10:11 am
Re: #include problem
Did you exit and restart the IDE (all instances of the IDE) after installing the libraries? The IDE doesn't recognize libraries that were installed after it starts up.
-
- Posts: 6
- Joined: Mon Jan 09, 2012 1:24 pm
Re: #include problem
Yes, many times over many days. It's holding up my project. For example, if I do the Datalogger sketch located under SD in the Examples menu. It works.
-
- Posts: 6
- Joined: Mon Jan 09, 2012 1:24 pm
Re: #include problem
BTW, I have been programming PICs for many years using my CCS C compiler and the CCS Mach X programmer. I'm trying Arduino as I like the shield concept. I'm getting tired of building circuit boards from scratch. This is supposed to be easier, yet I am stumped.
- adafruit_support_bill
- Posts: 88097
- Joined: Sat Feb 07, 2009 10:11 am
Re: #include problem
The "libraries" folder in the IDE install folder or your "Arduino" sketchbook folder. It should be under your sketchbook folder. On a PC, the path would be something like "My Documents/Arduino/Libraries". http://www.ladyada.net/library/arduino/libraries.htmlI have placed RTClib.h and RTC.cpp into an RTClib folder and placed that into the libraries folder.
You should unzip the entire contents of the RTClib folder from Github (including all sub-folders). Rename the resulting folder to "RTClib" and place it in the libraries folder.
- pburgess
- Posts: 4161
- Joined: Sun Oct 26, 2008 2:29 am
Re: #include problem
I'd suggest double-checking the spelling and "case" of the files/directories involved.
On Mac, for library 'Foo', the folder is:
/Users/username/Documents/Arduino/Libraries/Foo
For Windows:
C:/Users/username/My Documents/Arduino/Libraries/Foo
Containing:
Foo.cpp
Foo.h
examples
When properly installed, the example sketches will show up in the Sketchbook->Libraries->Foo rollover menu. If other libraries are appearing OK, make sure the folder and file names are an exact match.
On Mac, for library 'Foo', the folder is:
/Users/username/Documents/Arduino/Libraries/Foo
For Windows:
C:/Users/username/My Documents/Arduino/Libraries/Foo
Containing:
Foo.cpp
Foo.h
examples
When properly installed, the example sketches will show up in the Sketchbook->Libraries->Foo rollover menu. If other libraries are appearing OK, make sure the folder and file names are an exact match.
-
- Posts: 6
- Joined: Mon Jan 09, 2012 1:24 pm
Re: #include problem
I am using the Mac for this project as it is supposed to be the easiest to use. At any rate, I have done some more investigating on the Mac and found that if you right click on Arduino.app and then click on Show Package Contents, you will find the following: Contents>Resources>Java>Libraries. Ah, it seems that all of the libraries that come with the Arudino are in there. So I put the RTClib folder in there. By comparison it looks like all of the other folders in the library, Wire,Stepper, etc. It still ain't working. The cases are all correct. I created a dummy sketch and started installing the includes after I had restarted the IDE. All highlight, but not the ones I install. Something is not copasetic. I need someone who can cope with Macs with OS X 10.5.8. I wish I could send you a screen snap of my problem. Maybe we would have some more luck. As far as the last post is concerned, when I go to the File menu and then into the Sketchbook, all that shows up are the sketches that I have written. There is no rollover to a libraries folder.
- adafruit_support_bill
- Posts: 88097
- Joined: Sat Feb 07, 2009 10:11 am
Re: #include problem
The installer does not create the libraries folder by default. If this is the first library you have installed, you need to create the folder.
-
- Posts: 6
- Joined: Mon Jan 09, 2012 1:24 pm
Re: #include problem
And then where do I put this library in the Mac system? Is it the one I showed you earlier in the Java folder? Do I put it into the same folder with Arduino? I have tried both and they don't seem to be appropriate. Isn't there a video on YouTube that would show how to do this in a Mac environment? In the Arduino menu there should be a pull down menu with a function named "Import into library." You would then select a file, and the software should put it where it belongs. Why do I have to fool around with hierarchal folder management? It should be automatic.
I must be missing something and I don't know what it is.
I must be missing something and I don't know what it is.
- adafruit_support_bill
- Posts: 88097
- Joined: Sat Feb 07, 2009 10:11 am
Re: #include problem
On Mac, for library 'Foo', the folder is:And then where do I put this library in the Mac system?
/Users/username/Documents/Arduino/Libraries/Foo
-
- Posts: 27
- Joined: Thu Nov 17, 2011 12:43 am
Re: #include problem
I'm not sure case is important as my "library" folder is spelled with a lower-case "l"adafruit_support wrote:On Mac, for library 'Foo', the folder is:And then where do I put this library in the Mac system?
/Users/username/Documents/Arduino/Libraries/Foo
Also, the #include statement should use angle brackets ( <> ) rather than quotes ( "" ).
- westfw
- Posts: 2008
- Joined: Fri Apr 27, 2007 1:01 pm
Re: #include problem
If you copy the whole set of files (including examples) into your "libraries" folder, you can test things out by trying to compile one of the examples.
On my mac, the "libraries" folder is definitely all lower-case.
The libraries will probably NOT be highlighted, unless they include a "keywords.txt" file to define the keywords. When I tried one of the RTClib examples, the #include statement did not get highlighted (and there is no keywords.txt.) (This does not explain why it wouldn't compile, though.)
In order to make sure the IDE is all happy, I always use the Sketch/Import Library menu rather than typing the #include myself. This should make sure that you get the correct quotes vs brokets syntax (though I don't think that matters) and any other hints that the IDE might require about where to search for libraries. Also, if your library doesn't show up in the menu, you know that something is wrong.
The IDE is sometimes really fussy about directory names matching the file names, and is stricter than the native filesystems about filenames and such. The directory name in the libraries directory should match the top-level .h file that you include, regardless of zipfile name/etc.
Yes, an "install library" command for the IDE would be nice. With source code control and versioning. Using any of the half-dozen popular SCCS systems and/or file transfer mechanisms.
On my mac, the "libraries" folder is definitely all lower-case.
The libraries will probably NOT be highlighted, unless they include a "keywords.txt" file to define the keywords. When I tried one of the RTClib examples, the #include statement did not get highlighted (and there is no keywords.txt.) (This does not explain why it wouldn't compile, though.)
In order to make sure the IDE is all happy, I always use the Sketch/Import Library menu rather than typing the #include myself. This should make sure that you get the correct quotes vs brokets syntax (though I don't think that matters) and any other hints that the IDE might require about where to search for libraries. Also, if your library doesn't show up in the menu, you know that something is wrong.
The IDE is sometimes really fussy about directory names matching the file names, and is stricter than the native filesystems about filenames and such. The directory name in the libraries directory should match the top-level .h file that you include, regardless of zipfile name/etc.
Yes, an "install library" command for the IDE would be nice. With source code control and versioning. Using any of the half-dozen popular SCCS systems and/or file transfer mechanisms.
-
- Posts: 6
- Joined: Mon Jan 09, 2012 1:24 pm
Re: #include problem
Ah, my problem has been automagically solved. I now have identical libraries, one in the Arduino Java folder and one in the Arduino folder.
Thank you guys for all of your assistance. It works, but I'm not sure why. The sketches now compile and work just fine.
Thank you guys for all of your assistance. It works, but I'm not sure why. The sketches now compile and work just fine.
Please be positive and constructive with your questions and comments.