1

I've got this project that that is using the LiquidCrystal.h library. My import looks like this...

#import <LiquidCrystal.h>

I've tried making a 'libraries' folder in my repo, and copying the LiquidCrystal directory from arduino's global libraries folder to my_project/libraries and changing my import to...

#import "libraries/LiquidCrystal/LiquidCrystal.h"

and it explodes on me. I know the path is right, because it gives me a different error if I change the import path to be wrong... but even when it's right, I get this traceback...

Arduino: 1.8.1 (Mac OS X), TD: 1.36, Board: "Arduino/Genuino Uno"

/var/folders/sz/cdsmvqws6rq9839mhd802prm0000gp/T//cc4gIISN.ltrans0.ltrans.o: In function `__static_initialization_and_destruction_0':
/Users/chris/art/greenhouse/greenhouse/greenhouse.ino:36: undefined reference to `LiquidCrystal::LiquidCrystal(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char)'
etc....

What's the deal? Aren't I supposed to be able to import libraries with an absolute path to the library? This is literally the same file.

What is the difference between #import <foo.h> and #import "my_libraries/myfoo.h" ?

2

What's the deal? Aren't I supposed to be able to import libraries with an absolute path to the library? This is literally the same file.

Yes you can use both absolute and relative paths, but "libraries/LiquidCrystal/LiquidCrystal.h" is a relative path because it doesn't start from C:\\ or / basically. Also make sure you get the LiquidCrystal.cpp file which actually contains all the functions LiquidCrystal.h specifies.

What is the difference between #import and #import "my_libraries/myfoo.h" ?

#include "my_libraries/myfoo.h" specifies that myfoo.h is in a folder my_libraries first searched for in current_folder/my_libraries/myfoo.h then quote directories and rest of the search paths later, #include <foo.h> specifies that foo.h is a system header, it's only searched for in search paths.

Solution here would be saying inside your sketch that it is in a subfolder, that the folder is one folder below and then two folders deeper for ex. #include "../libraries/LiquidCrystal/LiquidCrystal.h" this here assumes your sketch is in root_folder/Sketch/Sketch.ino and library in root_folder/libraries/LiquidCrystal/LiquidCrystal.h.

1

Try it with this folder structure:

my_project
|_src
  |_LiquidCrystal

and change the import to:

#import "src/LiquidCrystal/LiquidCrystal.h"

Since Arduino IDE 1.6.10, recursive compilation of the sketch folder has been limited to the src subfolder (see Arduino/arduino-builder#148).

By the way, it's much more common to use #include instead of #import, which is deprecated and will cause a compiler warning. Any properly written library will not require the use of #import.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.