waywardgeek / infnoise

The world's easiest TRNG to get right
Creative Commons Zero v1.0 Universal
732 stars 100 forks source link

Incorrect linker flag (-lftdi) used because ldconfig not in path #53

Closed jdimpson closed 6 years ago

jdimpson commented 6 years ago

https://github.com/waywardgeek/infnoise/blob/fc0d99f58fff60b5cb7dca583f4bbcc60e1f63a2/software/Makefile#L14

Building on a Debian 9.4 amd64 system (up-to-date as of 3 day ago), with the official debian libftdi-dev package installed, which is at version 0.20-4. The infnoise software Makefile chose the wrong linker flag, apparently. Here's the output of make:

/bin/sh: 1: ldconfig: not found
cc -Wall -Wextra -Werror -std=c99 -O3 -I Keccak -I /usr/include/libftdi1 -DGIT_VERSION=\"Fourth-OshPark-Prototype-250-gfc0d99f\" -DGIT_COMMIT=\"fc0d99f58fff60b5cb7dca583f4bbcc60e1f63a2\" -DGIT_DATE=\"2018-04-10T06:52:23+02:00\" -DBUILD_DATE=\"2018-04-21T01:09:01-04:00\" -o infnoise infnoise.c healthcheck.c writeentropy.c daemon.c Keccak/KeccakF-1600-reference.c -lftdi1 -lm -lrt
/usr/bin/ld: cannot find -lftdi1
collect2: error: ld returned 1 exit status
Makefile:24: recipe for target 'infnoise' failed
make: *** [infnoise] Error 1

On Debian systems, ldconfig is found in /sbin, which is not in my unprivileged user's path. So the invocation of ldconfig failed, the FOUND variable was left empty, and thus the FTDI variable was set to -lftdi1 rather than -lftdi.

I changed the invocation of ldconfig to /sbin/ldconfig and the compilation was successful.

I notice that libftdi-config is installed in /usr/bin. When I run it as libftdi-config --libs, it prints -L/usr/lib/x86_64-linux-gnu -lftdi -lusb. That may be a more robust way to find the linker arguments.

Thank you!

manuel-domke commented 6 years ago

Thanks for the suggestion with libftdi-config. As it comes with libftdi-dev its a good option.