I am receiving a compilation error from
#include <HX711.h>
The error is
fatal error: HX711.h: No such file or directory
However, C:\Users\user\Documents\Arduino\libraries\HX711 is there and has the correct files in it. Sketch -> Include Library -> Manage libraries says that HX711 is installed. Strange thing is that I have another sketch that uses this library and it compiles. It uses quotes instead of angle brackets (which is strange because HX711.h is not in the same directory) and it works. I have tried both quotes and angle brackets.
EDIT: I am really sorry about typing "define" instead of "include" into the question my only excuse was that it was late. I copied the library directory to:
C:\Program Files (x86)\Arduino\libraries
and the problem remains.
I now have the HX711 directory in both the Arduino program files and the user directories and it still complains about it. The only way I can get it to compile is to place the hx711.h & hx711.cpp files directly into the sketch directory and change the line to #include "HX711.h"
EDIT: Running Arduino 1.6.5 on Windows 8.1 64bit
-
What platform are you using? (Windows. iOS, Linux) What IDE version are you using?Code Gorilla– Code Gorilla2016年11月24日 09:41:48 +00:00Commented Nov 24, 2016 at 9:41
-
@Matt Running Arduino 1.6.5 on Windows 8.1 64bitCarbonMan– CarbonMan2016年11月24日 10:32:36 +00:00Commented Nov 24, 2016 at 10:32
2 Answers 2
You're using #define
when it should be #include
.
-
I never saw that :DCode Gorilla– Code Gorilla2016年11月23日 12:52:50 +00:00Commented Nov 23, 2016 at 12:52
-
you can mark my answer as the solution then :)openTankist– openTankist2016年11月23日 12:54:30 +00:00Commented Nov 23, 2016 at 12:54
-
I thought the op had to do that.Code Gorilla– Code Gorilla2016年11月23日 16:09:37 +00:00Commented Nov 23, 2016 at 16:09
-
Very sorry @H.Woszczyk that was just a silly typo. The problem remains.CarbonMan– CarbonMan2016年11月23日 22:20:01 +00:00Commented Nov 23, 2016 at 22:20
Is the line of code really
#define <HX711.h>
If it is then replace <
with <
and that will fix it.
If the include statement has angle brackets <> around it then the file should be located in the system library folder, C:\Program Files\Arduino\Libraries
on Windows. I think there can now be a user library folder as well C:\Users\PHemans\Documents\Arduino\Libraries
and I think that the <> include will pick up from here too.
If the file is in you local folder (same place as the ino) then you should use "" the file name.
It is also possible that what you are seeing is not what the compiler is seeing, so deleting the whole line and then retyping it can sometimes work, as can checking the file endings and encodings using a tool like Notepad++.
-
I did what you suggested @Matt I now have the HX711 directory in both the Arduino program files and the user directories and it still complains about it. The only way I can get it to compile is to place the hx711.h & hx711.cpp files into the sketch directory and change the line to #include "HX711.h"CarbonMan– CarbonMan2016年11月23日 23:38:17 +00:00Commented Nov 23, 2016 at 23:38
-
Installing libraries to the IDE installation folder(C:\Program Files\Arduino\Libraries in your example) is a bad idea because all the libraries you install there will be lost when you update to a new IDE version. Always install the libraries to the {sketchbook}/libraries folder.per1234– per12342016年11月23日 23:52:59 +00:00Commented Nov 23, 2016 at 23:52