Pages: [1]   Go Down
Author Topic: IDE can’t fine library includes  (Read 2026 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I;m using the "softD1307" code in a project.  If i use the example code it properly finds the library includes for "SoftI2cMaster".  However when I move the code over to my project, the compiler complains that it cant; find SoftIc2Master.h TWIMaster.h.

If i copy the library code into my sketch directory all works fine.  Normaly this would indicate (in a Makefile world) that I don't have the search paths set up, but I cant figure out how to force the IDE to do this.
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16459
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to create a folder called libraries in your Arduino sketch directory and in there can be placed user library folders. Here is an example of where my user library folders are held so that the Arduino IDE can find them.

Quote
C:\Documents and Settings\Primary Windows User\My Documents\Arduino\libraries

9 Folders:

Button
DS1307
Flash
MsTimer2
Streaming
String
Tone
WString
__MACOSX


0 Files:

Lefty
« Last Edit: August 22, 2010, 12:44:58 pm by retrolefty » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I already have the SoftI2cMaster and TwiMaster libraries in the library directory
Logged

Maitland, Australia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 88
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

#include "some_lib.h"

... with double-quotes expects the file to be in the current folder.

#include <some_lib.h>

... with angle brackets will look for the file in a "libraries" folder.

Hope that's useful.

Prawnhead
Logged

There are 3 kinds of people in the world. Those who are good at maths, and those who aren't.

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Actually,  in the C language,  " means search local directories first, then the include path.   <> (chickenlips) means to search only the include path.   I have the includes correct.  if this was a makefile i'd just add the  -I <pathname> to the CC invocation.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 547
Posts: 45973
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where did you tell us what operating system you are using? Where did you tell us what version of the IDE you are using?

In the IDE, the Sketch + Import Library... menu item will list all libraries installed in the correct location(s). Are the libraries you are having difficulties with in that list?
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Version 18 of the IDE,  both Windows and MAC OSX.   The libraries do not show up in the list, which is strange because for all the other libraries which are working, i  just put the directories into the libraries directory.

Note, the softD1307 sample sketch finds the libraries correctly, but my sketch does not.  Again.. quite weird.  unfortunately I'm traveling and don't have the code with me at this time.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 547
Posts: 45973
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The simplest solution, then, is to note one of the library names that Sketch + Import Library... shows, and search on your computer for a folder with that name. Put the folders containing that libraries that you can't import into the folder that Import Library... can access.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is in the directory where the others are.  I think the problem is with including the files in a cpp file which i have as part of my sketch directory.  I will experiment with some test.code

Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As i have made the softD1307 a library a set of objects and methods, I have named my file softD1307.cpp.  With this, the paths are not found for the libraries.  When I change the name to softD1307.pde  i no longer get include errors.  So something is strange in the IDE when the file is a cpp and how paths are searched.
Logged

Pages: [1]   Go Up
Jump to: