I'm trying to compile a program but it throws the following error:
[cc] /usr/bin/ld: cannot find -ludev
I checked other topics on SO but the responses were to install something while I seem to be having libudev installed.
In /lib/x86_64-linux-gnu I also have:
lrwxrwxrwx 1 root root 16 lut 19 21:30 libudev.so.1 -> libudev.so.1.3.5
-rw-r--r-- 1 root root 67600 lut 19 21:31 libudev.so.1.3.5
I've tried linking libudev.so.0 to libudev.so.1 but it's still not working. What is ld looking for and why is it not working? How can I solve this?
When you use -lfoo
the linker will look for a file named libfoo.a
or libfoo.so
.
So in your case, you need libudev.so
without any suffix number.
Some Linux distributions, such as Debian and derivates (Ubuntu?), do not install these symlinks by default. So instead of creating that symlink yourself, try first looking for the *-dev
package (libudev-dev
).
ld
is the command for linker, you need to update your LIBPATH
variable to include the library location.
check the value of the env variable LIBPATH and change it to LIBPATH=LIBPATH:<lib location>
and compile again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With