Calibrating a Load Cell with HX711

I’m using source code to calibrate a load cell. Unfortunately, I’m not even able to get this program to compile. I’ve used it before, the only difference is it seems the library it references has updated and I have an updated version of Arduino Software.

The error seems to occur in the “linking everything together” stage. The last few lines of the error message are as follows:

ccspzhmz.ltrans0.o:(.text.startup+0x62): undefined reference to HX711::HX711(unsigned char, unsigned char, unsigned char)'** **C:\Users\KBAN62\AppData\Local\Temp\ccspzhmz.ltrans0.ltrans.o: In function main’:
ccspzhmz.ltrans0.o:(.text.startup+0x18a): undefined reference to HX711::set_scale(float)'** **ccspzhmz.ltrans0.o:(.text.startup+0x194): undefined reference to HX711::tare(unsigned char)'
ccspzhmz.ltrans0.o:(.text.startup+0x19e): undefined reference to HX711::read_average(unsigned char)'** **ccspzhmz.ltrans0.o:(.text.startup+0x200): undefined reference to HX711::set_scale(float)'
ccspzhmz.ltrans0.o:(.text.startup+0x212): undefined reference to HX711::get_units(unsigned char)'** **C:\Users\KBAN62\AppData\Local\Temp\ccspzhmz.ltrans0.ltrans.o: In function _GLOBAL__sub_D_scale’:
ccspzhmz.ltrans0.o:(.text.exit+0x4): undefined reference to `HX711::~HX711()'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.

Can someone guide me in the right direction for getting the code to compile?

loadcell_calibrate.ino (2.81 KB)

Can someone guide me in the right direction for getting the code to compile?

The code, referencing libraries you did not provide links to, DID compile. If it hadn't the linker wouldn't be trying to link anything together. It is the linker that can not find stuff it needs.

You need to post a link to (not just a URL) the library. (A link is clickable; a URL is not; links are created using the "Insert a link" icon).

PaulS here is your link. I do know the difference between a link and a url, but thanks for being extra explicit

I followed your link, downloaded and installed the library, and opened your sketch (using 1.6.5). I clicked the very icon, and got only one "error" message:

Global variables use 477 bytes (23%) of dynamic memory, leaving 1,571 bytes for local variables. Maximum is 2,048 bytes.

I'm using 1.6.12... Could that be a problem?

kbee54:
I'm using 1.6.12... Could that be a problem?

It is more likely that your library installation is flawed. I'd delete the library and re-download it.

It compiles and links using 1.6.9, too.

So I’ve deleted and reinstalled the libraries, the Arduino software, and restarted my computer.

Could there be a problem with my folder structure?

Again, here are the last few blurbs of the error message:

"C:\Users\KBAN62\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-gcc" -w -Os -flto -fuse-linker-plugin -Wl,–gc-sections -mmcu=atmega328p -o “C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332/loadcell_calibrate.ino.elf” “C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o” “C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\Q2HX711.cpp.o” “C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\loadcell_calibrate.ino.cpp.o” “C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o” “C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332/core\core.a” “-LC:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332” -lm
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::~HX711()'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::~HX711()'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::~HX711()'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::HX711()'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::HX711()'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::is_ready()'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::read()'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::set_gain(unsigned char)'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::begin(unsigned char, unsigned char, unsigned char)'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::HX711(unsigned char, unsigned char, unsigned char)'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::HX711(unsigned char, unsigned char, unsigned char)'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::read_average(unsigned char)'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::get_value(unsigned char)'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::get_units(unsigned char)'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::tare(unsigned char)'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::set_scale(float)'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::get_scale()'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::set_offset(long)'
Multiple libraries were found for "HX711.h"
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
Used: C:\Users\KBAN62\Documents\Arduino\libraries\HX711-master
Not used: C:\Program Files (x86)\Arduino\libraries\HX711-master
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::get_offset()'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::power_down()'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function HX711::~HX711()':** **(.text+0x0): multiple definition of HX711::power_up()'
C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
Using library HX711-master in folder: C:\Users\KBAN62\Documents\Arduino\libraries\HX711-master (legacy)
exit status 1
Error compiling for board Arduino/Genuino Uno.

C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\sketch\HX711.cpp.o (symbol from plugin):(.text+0x0): first defined here

C:\Users\KBAN62\AppData\Local\Temp\arduino_build_247332\libraries\HX711-master\HX711.cpp.o (symbol from plugin): In function `HX711::~HX711()':

You seem to have two copies of the library, now. One is in the sketch folder with the sketch. The other is in the libraries folder.

One copy of the library is preferred.

HI,

It also looks possible that you did not remove the “-master” from the library’s name before installing it.

–Michael