lampify icon indicating copy to clipboard operation
lampify copied to clipboard

Build fails undefined reference

Open littleboot opened this issue 2 years ago • 8 comments

Hello I'm trying to build 'lampify' but I'm unable to do so, I've tried building on Linux mint and Kali linux both fail the same way.

System info

Linux tom-mint 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Install dependencies:

sudo apt install libbluetooth-dev libnotify-dev make gcc

Missing deps not listed in readme

git

Clone repo in downloads folder

cd ~/Downloads git clone https://github.com/MasterDevX/lampify.git cd lampify

Try building

make

Build fail 1

/usr/include/glib-2.0/glib/gtypes.h:32:10: fatal error: glibconfig.h: No such file or directory
   32 | #include <glibconfig.h>

Fix

Seems the missing header file is located at a different location in my system: /usr/lib/x86_64-linux-gnu/glib-2.0/include Fix: add the missing path to the Makefile

Build fail 2

gcc -Wall -Ofast -I /usr/include/glib-2.0 -I /usr/lib/glib-2.0/include -I /usr/include/gdk-pixbuf-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -lbluetooth -lnotify -o lampify lampify.c
/usr/bin/ld: /tmp/ccvBgzpw.o: in function `hciSetParams':
lampify.c:(.text+0x13d4): undefined reference to `hci_send_req'
/usr/bin/ld: /tmp/ccvBgzpw.o: in function `sendPacket':
lampify.c:(.text+0x1430): undefined reference to `hci_get_route'
/usr/bin/ld: lampify.c:(.text+0x143f): undefined reference to `hci_open_dev'
/usr/bin/ld: lampify.c:(.text+0x14c7): undefined reference to `hci_send_req'
/usr/bin/ld: lampify.c:(.text+0x14f3): undefined reference to `hci_send_cmd'
/usr/bin/ld: lampify.c:(.text+0x150c): undefined reference to `hci_le_set_advertise_enable'
/usr/bin/ld: lampify.c:(.text+0x152c): undefined reference to `hci_le_set_advertise_enable'
/usr/bin/ld: lampify.c:(.text+0x1537): undefined reference to `hci_close_dev'
/usr/bin/ld: /tmp/ccvBgzpw.o: in function `decodeCommand':
lampify.c:(.text+0x17e9): undefined reference to `notify_init'
/usr/bin/ld: lampify.c:(.text+0x17f5): undefined reference to `notify_notification_new'
/usr/bin/ld: lampify.c:(.text+0x1805): undefined reference to `notify_notification_set_timeout'
/usr/bin/ld: lampify.c:(.text+0x180f): undefined reference to `notify_notification_show'
collect2: error: ld returned 1 exit status
make: *** [Makefile:9: all] Error 1

I don't know how to fix this issue, it seems the hci functions are depreciated in Bluez, this might be causing the problem. I have no clue on how to fix this, I hope someone is able to help

littleboot avatar Jul 12 '23 13:07 littleboot

Same problem with me :-(

Guenda85 avatar Sep 19 '23 07:09 Guenda85

to fix build fail #2 change the Makefile for the compilation to be - $(CC) $(BASE).c $(CFLAG) $(INC) $(LIB) -o $(BASE)

ophirHav avatar Oct 02 '23 20:10 ophirHav

@ophirHav I will try this out tomorrow (actually I already gave up so many thanks for your reply). Can you elaborate a bit?

so changing line 9 of the makefile from: $(CC) $(CFLAG) $(INC) $(LIB) -o $(BASE) $(BASE).c

To: $(CC) $(BASE).c $(CFLAG) $(INC) $(LIB) -o $(BASE)

It seems you only changed the order of the parameters passed to gcc, does this mean original make file was always incorrect or did gcc change or something. How did you arrive at this fix if I may ask?

Update: It works now, I can compile the program without errors, thank you very much!

littleboot avatar Oct 02 '23 21:10 littleboot

worked for me as well :-)

Guenda85 avatar Oct 05 '23 15:10 Guenda85

Newer versions of GCC have made the order of arguments relevant for linking and optimization purposes. That's why your sources should go first and then reference libraries the code uses.

yvesdm3000 avatar Nov 10 '23 12:11 yvesdm3000

I had to replace line 3 of the Makefile to use pkg-config to build on Ubuntu 22.04 :

INC   = -I /usr/include/glib-2.0 -I /usr/lib/glib-2.0/include -I /usr/include/gdk-pixbuf-2.0

with

INC   = $(shell pkg-config --cflags glib-2.0) $(shell pkg-config --cflags gdk-pixbuf-2.0)

t-chab avatar Apr 09 '24 17:04 t-chab

I had to replace line 3

For Ubuntu 24.04 also, this worked

micahchoo avatar Jun 17 '24 06:06 micahchoo

Yup, it built. Anyone else having the problem where it outputs [I] Connecting to the lamp [E] Failed to set advertising parameters!? I also tried running as root, but that didn't work. Also it doesn't make the light blink, and lights are unresponsive.

mak448a avatar Jul 05 '24 20:07 mak448a