amperka / ino

Command line toolkit for working with Arduino hardware
http://inotool.org
MIT License
1.08k stars 232 forks source link

Unable to find library, no such file or directory #205

Open chrisspen opened 9 years ago

chrisspen commented 9 years ago

I'm attempting to compile this simple bounce.ino example with ino, but it's giving me the error:

Bounce2.h: No such file or directory

I've placed it in the same directory as bounce.ino. I still get this error even if I use arduino to add the library to my ~/sketchbook/libraries folder.

Why can't it find the header? How do I specify that the local directory should also be checked for headers? Why can't ino see the libraries in the standard ~/sketchbook/libraries` folder?

tybenz commented 9 years ago

:+1: Same here! I've written my own .cpp and .h file in the src directory. ino build tries to compile Car.cpp but throws an error src/Car.cpp:2:17: error: Car.h: No such file or directory.

Is there something obvious that I'm missing?

translucide commented 9 years ago

The .cpp and .h files need to be in the lib folder in a subfolder named the same as the .h and .cpp in order for it to compile.

translucide commented 9 years ago

Ino also scans arduino librairies folder, but I hate to put libs there.... it gets scanned for all projects you make and first time compile is much longer because on that at least for me...

tybenz commented 9 years ago

Ok thanks for the clarification. The docs were a little confusing on this:

Here we have two directories. src is a source directory where we can put our project’s *.[c|cpp|pde|h|hpp] source files. sketch.ino was created for us, so we have a starting point. lib is a directory where we may put 3-rd party libraries if we would want.

The class I'm writing is not a 3rd party library. It's source code specific to the project, so I thought it belonged in src

translucide commented 9 years ago

If that can be of any help to you... here is how I work: I put my source code specific libs in project lib folder and symlink to the project lib folder the 3rd party libs from another lib folder i use to put all libs that will not change (3rd party or my general libs that I might use in multiple projects). That way I can maintain some libs for all my projects at the same place without putting them in the damn arduino librairies folder and not seeing them being compiled for nothing when I first compile a new project...

arcm111 commented 9 years ago

You can fix this issue by adding the following to environment.py at line 73:

lib_dir_extra = os.path.expanduser('~/sketchbook/libraries')

and changing the line in commands/build.py at 249 to:

lib_dirs = [self.e.arduino_core_dir] + list_subdirs(self.e.lib_dir) + list_subdirs(self.e.arduino_libraries_dir) + list_subdirs(self.e.lib_dir_extra)
cr7pt0 commented 9 years ago

After putting the library directory in both the lib directory as well as the /usr/share/arduino/libraries/ this was still not working. Did ino clean and then ino build and it worked.