From ee94eab6670481d7360a25fd12ddce71291ed0a3 Mon Sep 17 00:00:00 2001 From: lichtstrahlreiter <45295540+lichtstrahlreiter@users.noreply.github.com> Date: Fri, 23 Nov 2018 17:34:30 +0000 Subject: [PATCH] Fix linking Without this change I get the following error message: cc -c -o sysbacklight.o -I/usr/include/sysfs/ -Wall -std=c99 sysbacklight.c cc -o sysbacklight -lsysfs sysbacklight.o sysbacklight.o: In function `find_brightness_device': sysbacklight.c:(.text+0xe): undefined reference to `sysfs_open_class' sysbacklight.c:(.text+0x39): undefined reference to `sysfs_get_class_devices' sysbacklight.c:(.text+0x74): undefined reference to `dlist_start' sysbacklight.c:(.text+0x85): undefined reference to `_dlist_mark_move' sysbacklight.c:(.text+0x9c): undefined reference to `sysfs_get_classdev_attr' sysbacklight.c:(.text+0xdf): undefined reference to `_dlist_mark_move' sysbacklight.o: In function `get_brightness': sysbacklight.c:(.text+0x12d): undefined reference to `sysfs_get_classdev_attr' sysbacklight.c:(.text+0x16a): undefined reference to `sysfs_get_classdev_attr' sysbacklight.o: In function `set_brightness': sysbacklight.c:(.text+0x1f4): undefined reference to `sysfs_get_classdev_attr' sysbacklight.c:(.text+0x231): undefined reference to `sysfs_get_classdev_attr' sysbacklight.c:(.text+0x392): undefined reference to `sysfs_write_attribute' collect2: error: ld returned 1 exit status Makefile:7: recipe for target 'sysbacklight' failed make: *** [sysbacklight] Error 1 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0916454..3596973 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ LDFLAGS?=$(shell pkg-config --libs libsysfs) all: sysbacklight sysbacklight: sysbacklight.o - $(CC) -o $@ $(LDFLAGS) $< + $(CC) -o $@ $< $(LDFLAGS) %.o: %.c $(CC) -c -o $@ $(CFLAGS) $< -- 2.39.5