cmmk_ctrl icon indicating copy to clipboard operation
cmmk_ctrl copied to clipboard

Cannot build on Ubuntu: libusb linking problem

Open KlfJoat opened this issue 5 years ago • 3 comments

Background info

$ lsb_release --description --codename
Description:	Ubuntu 19.04
Codename:	disco
$ uname -a
Linux ruatha 5.0.0-27-generic #28-Ubuntu SMP Tue Aug 20 19:53:07 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

I have cloned this and the submodule to my Ubuntu system. I had build essentials, but I had to install a few extra dependencies...

sudo apt install libusb-1.0-0-dev
sudo apt install qt5-default
sudo apt install libqt5svg5-dev

However, now when I try to build, I get the following... (this is after it fails once, so the successful compilation/linking doesn't show up)

$ make
make -C libcmmk
make[1]: Entering directory '/home/klfjoat/src/cmmk_ctrl/libcmmk'
mkdir -p out
ar rcs out/libcmmk.a libcmmk.o
gcc -shared -s -Wall -Wextra -std=c99 -fPIC libcmmk.o -o out/libcmmk.so
gcc -s -Wall -Wextra -std=c99 -fPIC test.o -o out/cmmk-test -lcmmk -lusb-1.0 -Lout/
make[1]: Leaving directory '/home/klfjoat/src/cmmk_ctrl/libcmmk'
test -d build || mkdir build
cd build; qmake PREFIX= ..
make -j -C build
make[1]: Entering directory '/home/klfjoat/src/cmmk_ctrl/build'
g++  -o cmmk_ctrl main.o mainwindow.o KeyboardWidget.o KeyboardButton.o SpeedSlider.o ColorButton.o moc_mainwindow.o moc_KeyboardWidget.o moc_KeyboardButton.o moc_SpeedSlider.o moc_ColorButton.o   -lusb-1.0 -L../libcmmk/out -lcmmk -lQt5Svg -lQt5Widgets -lQt5Gui -lQt5Core /usr/lib/x86_64-linux-gnu/libGL.so -lpthread   
/usr/bin/ld: ../libcmmk/out/libcmmk.so: undefined reference to `libusb_get_device_descriptor'
/usr/bin/ld: ../libcmmk/out/libcmmk.so: undefined reference to `libusb_open_device_with_vid_pid'
/usr/bin/ld: ../libcmmk/out/libcmmk.so: undefined reference to `libusb_close'
/usr/bin/ld: ../libcmmk/out/libcmmk.so: undefined reference to `libusb_init'
/usr/bin/ld: ../libcmmk/out/libcmmk.so: undefined reference to `libusb_detach_kernel_driver'
/usr/bin/ld: ../libcmmk/out/libcmmk.so: undefined reference to `libusb_kernel_driver_active'
/usr/bin/ld: ../libcmmk/out/libcmmk.so: undefined reference to `libusb_attach_kernel_driver'
/usr/bin/ld: ../libcmmk/out/libcmmk.so: undefined reference to `libusb_free_device_list'
/usr/bin/ld: ../libcmmk/out/libcmmk.so: undefined reference to `libusb_claim_interface'
/usr/bin/ld: ../libcmmk/out/libcmmk.so: undefined reference to `libusb_interrupt_transfer'
/usr/bin/ld: ../libcmmk/out/libcmmk.so: undefined reference to `libusb_get_device_list'
/usr/bin/ld: ../libcmmk/out/libcmmk.so: undefined reference to `libusb_exit'
/usr/bin/ld: ../libcmmk/out/libcmmk.so: undefined reference to `libusb_release_interface'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:171: cmmk_ctrl] Error 1
make[1]: Leaving directory '/home/klfjoat/src/cmmk_ctrl/build'
make: *** [Makefile:11: cmmk_ctrl] Error 2

I've tried troubleshooting, but I'm not a dev. Googling for the ld errors brings up some options, but I tried all the items I found and none worked.

KlfJoat avatar Sep 03 '19 00:09 KlfJoat

@KlfJoat try adding -lusb-1.0 to call in libcmmk Makefile so the line looks like: ${CC} -shared ${CFLAGS} $^ -o out/[email protected] -lusb-1.0

JanBrezina avatar Dec 04 '19 08:12 JanBrezina

@JanBrezina

Thank you!!! That got me compiled!

But now I've got another problem. I run make install

$ sudo make install                                                                      
Executing sudo -- bash -x -v -c "make" 'install'                                                                                    
[sudo] password for klfjoat:                                                                                                        
"make" 'install'                                                                                                                    
+ make install                                                                                                                      
make -C build install                                                                                                               
make[1]: Entering directory '/home/klfjoat/src/cmmk_ctrl/build'                                                                     
/usr/lib/qt5/bin/qmake -install qinstall -exe cmmk_ctrl /usr/local/bin/cmmk_ctrl                                                    
/usr/lib/qt5/bin/qmake -install qinstall /home/klfjoat/src/cmmk_ctrl/img/key_11x4.svg /usr/local/share/cmmk_ctrl/img/key_11x4.svg   
/usr/lib/qt5/bin/qmake -install qinstall /home/klfjoat/src/cmmk_ctrl/img/key_25x4.svg /usr/local/share/cmmk_ctrl/img/key_25x4.svg   
/usr/lib/qt5/bin/qmake -install qinstall /home/klfjoat/src/cmmk_ctrl/img/key_4x4.svg /usr/local/share/cmmk_ctrl/img/key_4x4.svg     
/usr/lib/qt5/bin/qmake -install qinstall /home/klfjoat/src/cmmk_ctrl/img/key_4x8.svg /usr/local/share/cmmk_ctrl/img/key_4x8.svg
/usr/lib/qt5/bin/qmake -install qinstall /home/klfjoat/src/cmmk_ctrl/img/key_5x4.svg /usr/local/share/cmmk_ctrl/img/key_5x4.svg
/usr/lib/qt5/bin/qmake -install qinstall /home/klfjoat/src/cmmk_ctrl/img/key_6x4.svg /usr/local/share/cmmk_ctrl/img/key_6x4.svg
/usr/lib/qt5/bin/qmake -install qinstall /home/klfjoat/src/cmmk_ctrl/img/key_7x4.svg /usr/local/share/cmmk_ctrl/img/key_7x4.svg
/usr/lib/qt5/bin/qmake -install qinstall /home/klfjoat/src/cmmk_ctrl/img/key_8x4.svg /usr/local/share/cmmk_ctrl/img/key_8x4.svg
/usr/lib/qt5/bin/qmake -install qinstall /home/klfjoat/src/cmmk_ctrl/img/key_9x4.svg /usr/local/share/cmmk_ctrl/img/key_9x4.svg
/usr/lib/qt5/bin/qmake -install qinstall /home/klfjoat/src/cmmk_ctrl/img/key_iso_return.svg /usr/local/share/cmmk_ctrl/img/key_iso_return.svg
/usr/lib/qt5/bin/qmake -install qinstall -exe /home/klfjoat/src/cmmk_ctrl/libcmmk/out/libcmmk.so /usr/local/lib/libcmmk.so
make[1]: Leaving directory '/home/klfjoat/src/cmmk_ctrl/build'

But when I run the program, I get...

$ cmmk_ctrl 
cmmk_ctrl: error while loading shared libraries: libcmmk.so: cannot open shared object file: No such file or directory
$ which cmmk_ctrl 
/usr/local/bin/cmmk_ctrl

I've verified that it installed to /usr/local/bin/cmmk_ctrl and the library is in /usr/local/lib/libcmmk.so.

I have also verified that /usr/local/lib is declared in /etc/ld.so.conf.d/*

And I have run sudo ldconfig.

Any further assistance you can provide would be great!

KlfJoat avatar Dec 04 '19 22:12 KlfJoat

@KlfJoat to be honest I forced it. Tried manually installing to ~/.local (basically copying contents of dist) but that got me the same message. Then copied it to / .. So basically you probably need to copy libcmmk.so to /liband you current installation should run

JanBrezina avatar Dec 06 '19 10:12 JanBrezina