WootingKb / wooting-rgb-sdk

Customize colors on Wooting Keyboard #WootDev
Mozilla Public License 2.0
62 stars 15 forks source link

Linux compiling issues #36

Closed icaruseffect closed 3 years ago

icaruseffect commented 3 years ago

Hi can you give a hint how to compile this package on Arch linux? When I run make I get this error:

src/wooting-rgb-sdk/linux (git)-[makepkg] % cc -Wall -g -Wl,--no-as-needed `pkg-config libusb-1.0 --libs` `pkg-config hidapi-libusb --libs` -shared -fPIC -Wl,-soname,.0 ../src/wooting-rgb-sdk.o ../src/wooting-usb.o -o libwooting-rgb-sdk.so

/usr/bin/ld: ../src/wooting-usb.o: warning: relocation against `key_code_limit' in read-only section `.text'
/usr/bin/ld: ../src/wooting-usb.o: relocation R_X86_64_PC32 against symbol `key_code_limit' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value

libusb (1.0.23-3) and hidapi (0.10.1-1) are installed with pacman. The kernel is: 5.9.14-zen1-1-zen #1 ZEN SMP PREEMPT Sat, 12 Dec 2020 14:36:44 +0000 x86_64 GNU/Linux

simon-wh commented 3 years ago

Hmmm, that's quite frustrating. I use Arch Linux fairly regularly and haven't run into any issues like that. I just tried with a fresh clone of the repository with the same package versions you mentioned and had no problem. I don't really know what to make of that error you're getting

What compiler version do you have? I tried both latest gcc and clang and compiled fine.

What I find especially weird is that it suggests compiling with -fPIC but it is being compiled with that. It seems this was run in a makepkg, are you doing this from an AUR package or something? What commands are you running?

icaruseffect commented 3 years ago

Now it works replicable at least with a fresh pulled copy of the repo. I first wrote a quick PKGBUILD myself and then tested it with another PKGBUILD I found on Github to crosscheck (see 1).

I'm totally clueless about the compilation issue with makepkg. First time I have this issue with makepkg.
I'll have a look at the BBS as well, to figure out whats happening. A replicable/ automated build from AUR would be nice. When you find time you could check this on your arch machine as well. Maybe something in my system is just off.

$  clang -v
version 11.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/10.2.0
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
Found CUDA installation: /opt/cuda, version 11.

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC) 
simon-wh commented 3 years ago

Now it works replicable at least with a fresh pulled copy of the repo. I first wrote a quick PKGBUILD myself and then tested it with another PKGBUILD I found on Github to crosscheck (see 1).

I'm totally clueless about the compilation issue with makepkg. First time I have this issue with makepkg. I'll have a look at the BBS as well, to figure out whats happening. A replicable/ automated build from AUR would be nice.

Huh, it's weird it freaks out like that in makepkg, I haven't done much with makepkg before, so don't have much to say there, although I should take an evening to play around with it given https://github.com/WootingKb/wooting-analog-sdk/issues/14. A replicable build from the AUR would indeed be very nice

When you find time you could check this on your arch machine as well. Maybe something in my system is just off.

Here you go, on the surface looks pretty similar

❯ clang -v
clang version 11.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/sbin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Found candidate GCC installation: /usr/sbin/../lib/gcc/x86_64-pc-linux-gnu/10.2.0
Found candidate GCC installation: /usr/sbin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Selected GCC installation: /usr/sbin/../lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

~ 
❯ gcc -v                                          
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC) 
N00byKing commented 3 years ago

Hi,

I fixed the Issue for my PKGBUILD I think, could you please try the latest one? For the curious, the Linux Makefile (correctly) does not set CFLAGS if they are already set, and makepkg.conf does. So, we need to specify the -fPIC requirement. This does not happen when manually compiling, as on a normal system CFLAGS are unset. Thanks!

icaruseffect commented 3 years ago

Hi @N00byKing this little trick does it and compilation an installation works. A big thank you!

PastaJ36 commented 3 years ago

Anything we need to PR here? (Linux noob here)