Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to install opencv in my system by following this link. It says that after installing we need to do some configuration by opening

/etc/ld.so.conf.d/opencv.conf

and typing a particular address. And then in another one

/etc/bash.bashrc

we are writing

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

It will be great if someone can explain how does it help the process.

share|improve this question

1 Answer 1

You're telling various parts of the system how to find the opencv support libraries.

What the code does

The instructions that you cite say to add the following line to /etc/ld.so.conf.d/opencv.conf:

/usr/local/lib

Notice that /usr/local is in the bash config as well. When you build an application from source, the default install location is in the /usr/local subtree. The two configuration pieces you mention are there to make sure that the rest of the operating system knows to look in /usr/local/... in addition to the other usual places, for various libraries, etc. If you were to install into another location, say /usr or /opt, you'd want to change all those paths accordingly.

Why bother?

/etc/ld.so.conf (and /etc/ld.so.conf.d) are there to tell ld.so(8) where to find shared libraries. Since opencv installs in /usr/local/..., we need to have ld.so look in /usr/local/lib to find the support libraries for the app. Similarly for pkgconfig, we need to be sure the pkg-config app can find its support files.

Do you need to do this?

Now, you may not need to make the change suggested by the documentation. If you look at the other files in /etc/ld.so.conf.d, you may find that another file already includes /usr/local/lib:

grep /usr/local/lib /etc/ld.so.conf.d/*

On my system, this returns

/etc/ld.so.conf.d/libc.conf:/usr/local/lib

Because this is here, I wouldn't need a second entry, although it's safe to have it in twice. You may not need the PKG_CONFIG setup either, since the pkg-config(1) man page states:

On most systems, pkg-config looks in /usr/lib/pkgconfig, /usr/share/pkgconfig, /usr/local/lib/pkgconfig and /usr/local/share/pkgconfig for these files.

share|improve this answer

Your Answer

 
discard

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.