crepererum / tf1d

Traktor F1 userspace driver
GNU General Public License v2.0
10 stars 1 forks source link

Undefined references when compiling (Latest Ubuntu and GCC) #3

Closed benkuper closed 2 years ago

benkuper commented 3 years ago

Hello, I know it's been already 6 years but just in case you may find an easy solution, when compiling (with already libusb-1.0-0-dev and libasound2-dev installed), I get the following errors :

I could not find useful insight on internet, everybody just mentions installing libasound2-dev / libusb-1.0-0-dev but that's not changing it.

I also tried forcing using gcc-5 / 7 / 8

cc -std=gnu99 -O2 -lasound -lusb-1.0 -pthread -o target/tf1d tf1d.c
/usr/bin/ld: /tmp/ccD9Vi3e.o: in function `send_diff':
tf1d.c:(.text+0x7b): undefined reference to `snd_rawmidi_write'
/usr/bin/ld: tf1d.c:(.text+0xc7): undefined reference to `snd_rawmidi_write'
/usr/bin/ld: tf1d.c:(.text+0x106): undefined reference to `snd_rawmidi_write'
/usr/bin/ld: tf1d.c:(.text+0x142): undefined reference to `snd_rawmidi_write'
/usr/bin/ld: tf1d.c:(.text+0x174): undefined reference to `snd_rawmidi_write'
/usr/bin/ld: /tmp/ccD9Vi3e.o:tf1d.c:(.text+0x1a7): more undefined references to `snd_rawmidi_write' follow
/usr/bin/ld: /tmp/ccD9Vi3e.o: in function `send_diff':
tf1d.c:(.text+0x327): undefined reference to `snd_rawmidi_drain'
/usr/bin/ld: tf1d.c:(.text+0x353): undefined reference to `snd_strerror'
/usr/bin/ld: /tmp/ccD9Vi3e.o: in function `thread_input':
tf1d.c:(.text+0x5ff): undefined reference to `libusb_bulk_transfer'
/usr/bin/ld: tf1d.c:(.text+0x611): undefined reference to `libusb_error_name'
/usr/bin/ld: /tmp/ccD9Vi3e.o: in function `main':
tf1d.c:(.text.startup+0x1f): undefined reference to `libusb_init'
/usr/bin/ld: tf1d.c:(.text.startup+0x38): undefined reference to `libusb_open_device_with_vid_pid'
/usr/bin/ld: tf1d.c:(.text.startup+0x51): undefined reference to `libusb_set_auto_detach_kernel_driver'
/usr/bin/ld: tf1d.c:(.text.startup+0x5b): undefined reference to `libusb_claim_interface'
/usr/bin/ld: tf1d.c:(.text.startup+0x6b): undefined reference to `libusb_get_device'
/usr/bin/ld: tf1d.c:(.text.startup+0x76): undefined reference to `libusb_get_active_config_descriptor'
/usr/bin/ld: tf1d.c:(.text.startup+0x96): undefined reference to `libusb_free_config_descriptor'
/usr/bin/ld: tf1d.c:(.text.startup+0xae): undefined reference to `snd_rawmidi_open'
/usr/bin/ld: tf1d.c:(.text.startup+0x159): undefined reference to `snd_rawmidi_close'
/usr/bin/ld: tf1d.c:(.text.startup+0x163): undefined reference to `snd_rawmidi_close'
/usr/bin/ld: tf1d.c:(.text.startup+0x16d): undefined reference to `libusb_release_interface'
/usr/bin/ld: tf1d.c:(.text.startup+0x175): undefined reference to `libusb_close'
/usr/bin/ld: tf1d.c:(.text.startup+0x17c): undefined reference to `libusb_exit'
/usr/bin/ld: tf1d.c:(.text.startup+0x185): undefined reference to `libusb_error_name'
/usr/bin/ld: tf1d.c:(.text.startup+0x1a9): undefined reference to `libusb_close'
/usr/bin/ld: tf1d.c:(.text.startup+0x1b0): undefined reference to `libusb_exit'
/usr/bin/ld: tf1d.c:(.text.startup+0x1e7): undefined reference to `snd_strerror'
/usr/bin/ld: tf1d.c:(.text.startup+0x218): undefined reference to `libusb_exit'
crepererum commented 3 years ago

I've just tried this locally again it for me it still works. I honestly don't know why the libraries are not found on your system.

benkuper commented 3 years ago

I've tested with 2 ubuntu systems, I can't make it work.. could you log your OS version, gcc and other tools that you use ? Also if it's possible at all, it would be great to have a release binary for standard archs (like Ubuntu, it would make it a bit easier to deploy :)

I know this is a very old project so I don't expect much there :)

benkuper commented 3 years ago

Just tried again on a fresh ubuntu 20.10 install, the only lines I wrote are those ones :

sudo apt update
sudo apt install git
sudo apt install build-essential
sudo apt install libasound2-dev
sudo apt install libusb-1.0-0-dev

git clone https://github.com/crepererum/tf1d
cd tf1d
make

and the output is mostly the same :

osboxes@osboxes:~/Desktop/tf1d$ make
mkdir -p target
cc -std=gnu99 -O2 -lasound -lusb-1.0 -pthread -o target/tf1d tf1d.c
/usr/bin/ld: /tmp/cc6yeHXK.o: in function `send_diff':
tf1d.c:(.text+0x7b): undefined reference to `snd_rawmidi_write'
/usr/bin/ld: tf1d.c:(.text+0xc7): undefined reference to `snd_rawmidi_write'
/usr/bin/ld: tf1d.c:(.text+0x106): undefined reference to `snd_rawmidi_write'
/usr/bin/ld: tf1d.c:(.text+0x142): undefined reference to `snd_rawmidi_write'
/usr/bin/ld: tf1d.c:(.text+0x174): undefined reference to `snd_rawmidi_write'
/usr/bin/ld: /tmp/cc6yeHXK.o:tf1d.c:(.text+0x1a7): more undefined references to `snd_rawmidi_write' follow
/usr/bin/ld: /tmp/cc6yeHXK.o: in function `send_diff':
tf1d.c:(.text+0x327): undefined reference to `snd_rawmidi_drain'
/usr/bin/ld: tf1d.c:(.text+0x353): undefined reference to `snd_strerror'
/usr/bin/ld: /tmp/cc6yeHXK.o: in function `thread_input':
tf1d.c:(.text+0x5ff): undefined reference to `libusb_bulk_transfer'
/usr/bin/ld: tf1d.c:(.text+0x611): undefined reference to `libusb_error_name'
/usr/bin/ld: /tmp/cc6yeHXK.o: in function `main':
tf1d.c:(.text.startup+0x1f): undefined reference to `libusb_init'
/usr/bin/ld: tf1d.c:(.text.startup+0x38): undefined reference to `libusb_open_device_with_vid_pid'
/usr/bin/ld: tf1d.c:(.text.startup+0x51): undefined reference to `libusb_set_auto_detach_kernel_driver'
/usr/bin/ld: tf1d.c:(.text.startup+0x5b): undefined reference to `libusb_claim_interface'
/usr/bin/ld: tf1d.c:(.text.startup+0x6b): undefined reference to `libusb_get_device'
/usr/bin/ld: tf1d.c:(.text.startup+0x76): undefined reference to `libusb_get_active_config_descriptor'
/usr/bin/ld: tf1d.c:(.text.startup+0x96): undefined reference to `libusb_free_config_descriptor'
/usr/bin/ld: tf1d.c:(.text.startup+0xae): undefined reference to `snd_rawmidi_open'
/usr/bin/ld: tf1d.c:(.text.startup+0x159): undefined reference to `snd_rawmidi_close'
/usr/bin/ld: tf1d.c:(.text.startup+0x163): undefined reference to `snd_rawmidi_close'
/usr/bin/ld: tf1d.c:(.text.startup+0x16d): undefined reference to `libusb_release_interface'
/usr/bin/ld: tf1d.c:(.text.startup+0x175): undefined reference to `libusb_close'
/usr/bin/ld: tf1d.c:(.text.startup+0x17c): undefined reference to `libusb_exit'
/usr/bin/ld: tf1d.c:(.text.startup+0x185): undefined reference to `libusb_error_name'
/usr/bin/ld: tf1d.c:(.text.startup+0x1a9): undefined reference to `libusb_close'
/usr/bin/ld: tf1d.c:(.text.startup+0x1b0): undefined reference to `libusb_exit'
/usr/bin/ld: tf1d.c:(.text.startup+0x1e7): undefined reference to `snd_strerror'
/usr/bin/ld: tf1d.c:(.text.startup+0x218): undefined reference to `libusb_exit'
collect2: error: ld returned 1 exit status
make: *** [Makefile:10: target/tf1d] Error 1

This time it using gcc 10.2.0

draeron commented 2 years ago

found the solution here https://github.com/martin31821/fusion-kbd-controller/issues/2#issuecomment-442882261

In the makefile, the tf1d.c should be before the lib argument. This compiled on a raspberry pi running on bullseye debian.

target/tf1d: tf1d.c
        mkdir -p target
        $(CC) tf1d.c -std=gnu99 -O2 -lasound -lusb-1.0 -lusb -pthread -o target/tf1d
crepererum commented 2 years ago

@draeron fixed on master, thank you! :slightly_smiling_face: