Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not detecting library directory #497

Open
chrisspen opened this issue May 28, 2017 · 12 comments
Open

Not detecting library directory #497

chrisspen opened this issue May 28, 2017 · 12 comments

Comments

@chrisspen
Copy link

I have a number of extra libraries installed in /home/$USER/Arduino/libraries, which I can compile with from inside the Arduino IDE. However, if I try to compile with the makefile, I get the error:

The following libraries specified in ARDUINO_LIBS could not be found (searched USER_LIB_PATH and ARDUINO_LIB_PATH)

Please add support for custom library paths.

I tried setting USER_LIB_PATH, but this doesn't appear to support $USER or ~, and my application doesn't allow hard-coding the username in the path, since it's not a static value.

@sej7278
Copy link
Collaborator

sej7278 commented May 28, 2017

Use $(HOME) instead of ~ in Makefiles

See Blink example and issue #320

@chrisspen
Copy link
Author

chrisspen commented May 28, 2017

Ok. In that case, the docs should probably be updated. This explicitly says ~ should work. But you're right, it looks like $(HOME) and $(USER) variables are available.

Is it possible to include relative directories? I have a library in the same directory as my makefile, and to simplify installation and maintainability, I'd prefer to avoid having to copy it into my sketchbook.

However, if I use the setting:

USER_LIB_PATH = .

it still complains that it can't find the library.

@sej7278
Copy link
Collaborator

sej7278 commented May 28, 2017

have a look through the other issues, there's a few regarding libraries in the sketch directory, don't think its possible, but paths like "." are never going to work in a Makefile

@chrisspen
Copy link
Author

chrisspen commented May 28, 2017

Is appending multiple paths to USER_LIB_PATH supported? This blog post raves about Arduino-Makefile, claiming it has this ability, but when I use their syntax, e.g.

USER_LIB_PATH = /home/$(USER)/Arduino/libraries
USER_LIB_PATH += $(realpath .)

it causes make to not find any libraries. Whereas each path by itself at least allows make to find the libraries at those paths:

e.g. This partially works (it finds libraries in my sketchbook, but not in the cwd):

USER_LIB_PATH = /home/$(USER)/Arduino/libraries

and this partially works (it finds libraries in my cwd, but not in my sketchbook):

USER_LIB_PATH = $(realpath .)

@sej7278
Copy link
Collaborator

sej7278 commented Jun 1, 2017

fixed the tilde documentation issue in PR #500 now merged

@chrisspen
Copy link
Author

My end goal is to allow inclusion of a local ./lib directory, so I don't have to copy every project's libraries into the global sketchbook directory, since that becomes difficult to maintain and inevitably results in conflicts.

Is there any way to currently accomplish this with Arduino-Makefile?

@ladislas
Copy link
Contributor

@chrisspen - I did something similar with the bare arduino project

@ladislas
Copy link
Contributor

@chrisspen and actually you'll need to take a look at our fork of the arduino-makefile https://github.com/weareleka/Arduino-Makefile

@chrisspen
Copy link
Author

Is there no solution for this?

My code looks like:

src/
    lib/
        OtherLibrary/
            some_include.h
            some_other_include.h
    main.ino

My makefile looks like:

BOARD_TAG    = uno
MONITOR_PORT = /dev/ttyACM0
AVRDUDE_OPTS = -v
ARDUINO_LIBS = OtherLibrary
ARDUINO_SKETCHBOOK = $(realpath .)/lib
USER_LIB_PATH = $(realpath .)/lib
include /usr/share/arduino/Arduino.mk

But when I run make, I get the error:

In file included from main.ino:40:0:
some_include.h:3:45: fatal error: OtherLibrary/some_other_include.h: No such file or directory
 #include "OtherLibrary/some_include.h"

Why isn't it finding secondary includes in either the ARDUINO_SKETCHBOOK or USER_LIB_PATH?

I noticed that, for some odd reason, the g++ command outputted doesn't actually include either of these paths as a -I option, and if I manually add that path and call g++ myself, it compiles perfectly.

Am I not configuring arduino-mk correctly, or is this a bug? This seems like a very simple feature that isn't working.

@chrisspen
Copy link
Author

chrisspen commented Jun 19, 2017

The problem seems to be that arduino-mk completely ignores ARDUINO_SKETCHBOOK, and it doesn't directly include USER_LIB_PATH but instead uses that as a base folder to include the sub-folders that match items in ARDUINO_LIBS. So it's not finding OtherLibrary/some_include.h because it's not using ../OtherLibrary as a search path.

However, why isn't ARDUINO_SKETCHBOOK being used? If I comment out my custom USER_LIB_PATH, then I get the completely nonsensical error message:

 *** The following libraries specified in ARDUINO_LIBS could not be found (searched USER_LIB_PATH, ARDUINO_LIB_PATH and ARDUINO_PLATFORM_LIB_PATH): OtherLibrary

Yes...it'd be found if it checked ARDUINO_SKETCHBOOK. Why isn't that being used as a search path?

@sej7278
Copy link
Collaborator

sej7278 commented Jun 19, 2017

@ladislas i thought you wrote some sort of library autodetection script but your fork seems identical to upstream now?

@chrisspen ARDUINO_SKETCHBOOK is not the right place to search for libraries and shouldn't be dynamic between sketches. you probably want to create another variable to achieve what you want.

@ladislas
Copy link
Contributor

@sej7278 I'm following upstream (you) closely and then reapplying my changes each time.

you have to checkout the auto-lib branch: https://github.com/weareleka/Arduino-Makefile/tree/auto-lib

here are the differences

leka@42c8bdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants