Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ld cannot find udev

Tags:

linux

ld

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?

like image 565
user294034 Avatar asked Apr 14 '15 08:04

user294034


2 Answers

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).

like image 123
rodrigo Avatar answered Oct 31 '22 18:10

rodrigo


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.

like image 30
Steephen Avatar answered Oct 31 '22 16:10

Steephen