Compilation error: Undefined reference to

4.7k views Asked by At

I'm working on a C program for getting events from Udev. The program has been compiled and tested on a host running Debian (With GCC 4.7.2-5).

Recently, switched to Ubuntu 12.04 LTS (With GCC 4.6.3). The same program fails to compile and halts during the linking phase.

automounter_main.c:(.text+0xd4e): undefined reference to `udev_new'
automounter_main.c:(.text+0xe02): undefined reference to `udev_device_new_from_devnum'
automounter_main.c:(.text+0xeb0): undefined reference to `udev_device_new_from_syspath'
automounter_main.c:(.text+0xf63): undefined reference to `udev_device_get_sysattr_list_entry'
automounter_main.c:(.text+0xf77): undefined reference to `udev_list_entry_get_name'
automounter_main.c:(.text+0xf85): undefined reference to `udev_device_get_sysattr_value'
automounter_main.c:(.text+0x100a): undefined reference to `udev_device_get_sysattr_value'
automounter_main.c:(.text+0x1055): undefined reference to `udev_device_get_sysattr_value'
automounter_main.c:(.text+0x1078): undefined reference to `udev_list_entry_get_next'
automounter_main.c:(.text+0x108c): undefined reference to `udev_device_get_parent'
automounter_main.c:(.text+0x1118): undefined reference to `udev_device_unref'
automounter_main.c:(.text+0x1122): undefined reference to `udev_unref'

The following steps were taken, but nothing seems to work.

  • Install all packages related to udev (udev, libudev-dev, libudev0). All the packages are reported to be the latest.
  • Create a Symlink in /usr/lib pointing the correct udev library.
  • Upgraded libc package

Symlink was verified using:

$ ls -l libudev*

lrwxrwxrwx 1 root root    39 Nov 27 15:57 libudev.so -> /lib/x86_64-linux-gnu/libudev.so.0.13.0)

Kindly help me find a way to resolve this error.

Thanks in advance.

1

There are 1 answers

1
Lars Brinkhoff On BEST ANSWER

My guess would be that you need to move -ludev to the end of the linking command line.