Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got different versions of the Libnet library installed in different locations on the same system:

whereis libnet
libnet: /usr/lib/libnet.la /usr/lib/libnet.a /usr/lib/libnet.so /usr/local/lib/libnet.la /usr/local/lib/libnet.a /usr/local/lib/libnet.so /usr/include/libnet.h /usr/include/libnet /usr/man/man3/libnet.3

I have some problems with compiling a program that depends on these libnet libraries so I want to remove the "usr/local/...."-ones. Can you tell me how to do that, i.e, when I whereis libnet on the command line I want to not see the "/usr/local/..." references ?!

Thank you!

share|improve this question
up vote 0 down vote accepted

I have some problems with compiling a program that depends on these libnet libraries so I want to remove the /usr/local/-ones

It is generally not necessary to remove the library located in /usr/local. So don't get fooled by whereis. You can specify library paths where libraries should be searched first by means of the LD_LIBRARY_PATH environment variable.

In your case, you have to add /usr/lib to LD_LIBRARY_PATH and append the variable to the environment of your make process. This is usually done by

$ export LD_LIBRARY_PATH=/usr/lib

before starting the make process or by prefixing the related command with the parameter assignment. Usually that looks like

$ LD_LIBRARY_PATH=/usr/lib ./configure

If you really want to get rid of the library under /usr/local you first have to clarify a question.

How did you install the library (since it's under /usr/local it's likely that you did it):

  • with your package manager
  • by means of make install
  • just moved the binary to the directory
share|improve this answer
I think ld will prefer shared libraries over static ones. – vonbrand Jan 28 '13 at 15:12
Hello! It's under /usr/local by make install . – kawa Jan 28 '13 at 16:59
If you still have the corresponding makefile and are lucky enough that it implements the uninstall target a simple make uninstall should remove all files that were previously installed. – user1146332 Jan 28 '13 at 19:03
thans but I solved it another way. In /usr/local I installed the libraries and includes that are the correct version (the program I compiled searches for them there) by ./configure --prefix=/usr/local && and the bad files were overwitten. Compiling works now. – kawa Jan 30 '13 at 18:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.