1

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

2
  • What platform are you using? (Windows. iOS, Linux) What IDE version are you using? Nov 24, 2016 at 9:41
  • @Matt Running Arduino 1.6.5 on Windows 8.1 64bit
    – CarbonMan
    Nov 24, 2016 at 10:32

2 Answers 2

2

You're using #define when it should be #include.

4
  • I never saw that :D Nov 23, 2016 at 12:52
  • you can mark my answer as the solution then :) Nov 23, 2016 at 12:54
  • I thought the op had to do that. Nov 23, 2016 at 16:09
  • Very sorry @H.Woszczyk that was just a silly typo. The problem remains.
    – CarbonMan
    Nov 23, 2016 at 22:20
0

Is the line of code really

#define &lt;HX711.h>

If it is then replace &lt; 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++.

2
  • 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
    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
    Nov 23, 2016 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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