donniebreve / touchcursor-linux

TouchCursor style keyboard remapping for Linux.
GNU General Public License v2.0
133 stars 28 forks source link

Can't compile #63

Closed anakojm closed 1 year ago

anakojm commented 1 year ago

Hi, I am trying to compile touchcursor but I get the following error:

❯ make
gcc -g -Wall -c src/binding.c -o obj/binding.o
gcc -g -Wall -c src/config.c -o obj/config.o
gcc -g -Wall -c src/emit.c -o obj/emit.o
gcc -g -Wall -c src/keys.c -o obj/keys.o
gcc -g -Wall -c src/main.c -o obj/main.o
gcc -g -Wall -c src/mapper.c -o obj/mapper.o
gcc -g -Wall -c src/queue.c -o obj/queue.o
gcc -g -Wall -c src/strings.c -o obj/strings.o
gcc  ./obj/binding.o  ./obj/config.o  ./obj/emit.o  ./obj/keys.o  ./obj/main.o  ./obj/mapper.o  ./obj/queue.o  ./obj/strings.o -Wall -o out/touchcursor
/usr/bin/ld: ./obj/main.o: in function `read_watch_events':
/home/anako/Documents/git/touchcursor-linux/src/main.c:108: undefined reference to `pthread_kill'
/usr/bin/ld: /home/anako/Documents/git/touchcursor-linux/src/main.c:119: undefined reference to `pthread_kill'
/usr/bin/ld: ./obj/main.o: in function `watch_configuration_file':
/home/anako/Documents/git/touchcursor-linux/src/main.c:143: undefined reference to `pthread_create'
/usr/bin/ld: ./obj/main.o: in function `release_configuration_file_watch':
/home/anako/Documents/git/touchcursor-linux/src/main.c:154: undefined reference to `pthread_kill'
/usr/bin/ld: /home/anako/Documents/git/touchcursor-linux/src/main.c:155: undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make: *** [Makefile:29: out/touchcursor] Error 1

I am on azerty, debian and sway. Tell me if you need more info.

(note that this is not a duplicate of #35)

donniebreve commented 1 year ago

Hello @anakojm, from what I've read, you need to add -pthread to the gcc options in the Makefile.

diff --git a/Makefile b/Makefile
index 5922e9a..6d6a24d 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ out_path = ./out
 binary = touchcursor
 # LIBS = -lm
 cc = gcc
-cflags = -g -Wall
+cflags = -pthread -g -Wall
 # All .h files
 headers = $(wildcard $(src_path)/*.h)
 # All .c files, excluding test.c

I'm not sure why it worked before for me and others, but it doesn't seem to hurt anything to have that flag present. I've updated the make file if you would like to simply git pull.

anakojm commented 1 year ago

I pulled but I am still getting the same error, even with the pthread flag

(error) ```bash gcc -pthread -g -Wall -c src/binding.c -o obj/binding.o gcc -pthread -g -Wall -c src/config.c -o obj/config.o gcc -pthread -g -Wall -c src/emit.c -o obj/emit.o gcc -pthread -g -Wall -c src/keys.c -o obj/keys.o gcc -pthread -g -Wall -c src/main.c -o obj/main.o gcc -pthread -g -Wall -c src/mapper.c -o obj/mapper.o gcc -pthread -g -Wall -c src/queue.c -o obj/queue.o gcc -pthread -g -Wall -c src/strings.c -o obj/strings.o gcc ./obj/binding.o ./obj/config.o ./obj/emit.o ./obj/keys.o ./obj/main.o ./obj/mapper.o ./obj/queue.o ./obj/strings.o -Wall -o out/touchcursor /usr/bin/ld: ./obj/main.o: in function `read_watch_events': /home/anako/Documents/git/touchcursor-linux/src/main.c:108: undefined reference to `pthread_kill' /usr/bin/ld: /home/anako/Documents/git/touchcursor-linux/src/main.c:119: undefined reference to `pthread_kill' /usr/bin/ld: ./obj/main.o: in function `watch_configuration_file': /home/anako/Documents/git/touchcursor-linux/src/main.c:143: undefined reference to `pthread_create' /usr/bin/ld: ./obj/main.o: in function `release_configuration_file_watch': /home/anako/Documents/git/touchcursor-linux/src/main.c:154: undefined reference to `pthread_kill' /usr/bin/ld: /home/anako/Documents/git/touchcursor-linux/src/main.c:155: undefined reference to `pthread_join' collect2: error: ld returned 1 exit status make: *** [Makefile:29: out/touchcursor] Error 1 ```

I found a patch that work that I'll submit in a PR

donniebreve commented 1 year ago

Nice catch. #65 has been merged.