unix Library path variables.

Library path variables.

I need to know the library rnvironment variable in linux. Ie, I install zlib directory in the custom path /usr/local/mylib and give --enable-zlib in the ffmpeg install, ffmpeg should check for the zlib libraries in the path /usr/local/mylib. Currently it checks /usr/lib if 32 bit OS and in /usr/lib64/ if 64 bit. So, I need to set the library Env path, so that it will set to /usr/local/mylib during the compilation time.

Eg, like this.
PKG_CONFIG_PATH=/usr/lib/pkgconfig
export PKG_CONFIG_PATH

For static libraries, set LDFLAGS env var like this:

LDFLAGS=-L/usr/local/mydir 

If you do ./configure --help it will tell you more

Thank you.

I compiled libogg-1.2.2 with ./configure --prefix=/usr/local/myapps --with-pic
It got installed fine.

[root@ffmpeg src]# ll //usr/local/myapps/lib/libogg.*
-rw-r--r-- 1 root root 75792 Jun 24 09:05 //usr/local/myapps/lib/libogg.a
-rwxr-xr-x 1 root root   935 Jun 24 09:05 //usr/local/myapps/lib/libogg.la
lrwxrwxrwx 1 root root    15 Jun 24 09:05 //usr/local/myapps/lib/libogg.so -> libogg.so.0.7.1
lrwxrwxrwx 1 root root    15 Jun 24 09:05 //usr/local/myapps/lib/libogg.so.0 -> libogg.so.0.7.1
-rwxr-xr-x 1 root root 58396 Jun 24 09:05 //usr/local/myapps/lib/libogg.so.0.7.1
[root@ffmpeg src]# ll /usr/local/myapps/include/ogg/*
-rw-r--r-- 1 root root  500 Jun 24 09:05 //usr/local/myapps/include/ogg/config_types.h
-rw-r--r-- 1 root root 8347 Jun 24 09:05 /usr/local/myapps/include/ogg/ogg.h
-rw-r--r-- 1 root root 4275 Jun 24 09:05 /usr/local/myapps/include/ogg/os_types.h

Then I typed the following

[root@ffmpeg /]# LDFLAGS=-L/usr/local/myapps
[root@ffmpeg /]# export  LDFLAGS
[root@ffmpeg /]# echo $LDFLAGS
-L/usr/local/myapps

Then compile libvorbis with ./configure --prefix=/usr
It needs libogg.so and it is not checking the /usr/local/myapps dir for the libraries. It checks /usr/lib or /usr/lib64. I am not sure. How to make it check /usr/local/myapps by default? See the error below.

checking for OGG... no
checking for Ogg... no
*** Could not run Ogg test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means Ogg was incorrectly installed
*** or that you have moved Ogg since it was installed.
configure: error: must have Ogg installed!

I should say the .pc file of libogg has got the details. But all packages dont make .pc files.

[root@ffmpeg  / ]# cat  //usr/local/myapps/lib/pkgconfig/ogg.pc
# ogg pkg-config file

prefix=/usr/local/myapps
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: ogg
Description: ogg is a library for manipulating ogg bitstreams
Version: 1.2.2
Requires:
Conflicts:
Libs: -L${libdir} -logg
Cflags: -I${includedir}

When I issue the following commands, libvorbis configure script will not throw error.

[root@ffmpeg /]# PKG_CONFIG_PATH=/usr/local/myapps/lib/pkgconfig
[root@ffmpeg /]# export PKG_CONFIG_PATH

I need the configure script check /usr/local/myapps/lib without using PKG_CONFIG_PATH variable.

But that's not where your libs are. You should set LDFLAGS to -L/usr/local/myapps/lib

BTW, it doesn't need .so. That's dynamic library (shared object), that gets loaded at runtime. It wants the static library libogg.a to link against.

It's likely that you will need to define the path to header files also, export

CPPFLAGS=-I/usr/local/myapps/include

And as I am looking at the output of ./configure --help (of some other program, but should be same), I read:

--with-zlib[=DIR]       use zlib (located in directory DIR, if supplied) for
                          gzip compression and decompression . [default=yes,
                          if available]

So the following should take care of it, without messing with env vars:

./configure --with-ogg=/path/to/ogg

Two questions:

I)

Thank you. I ran these commands.

[root@ffmpeg /]# PKG_CONFIG_PATH=/usr/local/myapps/lib
[root@ffmpeg /]# PKG_CONFIG_PATH=/usr/local/myapps/lib/pkgconfig
[root@ffmpeg /]# export PKG_CONFIG_PATH
[root@ffmpeg /]# LDFLAGS=-L/usr/local/myapps/lib
[root@ffmpeg /]# export LDFLAGS
[root@ffmpeg /]# CPPFLAGS=-I/usr/local/myapps/include
[root@ffmpeg /]# export CPPFLAGS
[root@ffmpeg /]#
[root@ffmpeg /]# echo $PKG_CONFIG_PATH
/usr/local/myapps/lib/pkgconfig
[root@ffmpeg /]#
[root@ffmpeg /]# echo $LDFLAGS
-L/usr/local/myapps/lib
[root@ffmpeg /]#
[root@ffmpeg /]# echo $CPPFLAGS
-I/usr/local/myapps/include

Then installed libraw1394. The files got installed fine in the following locations.

/usr/local/myapps/include/libraw1394
/usr/local/myapps/include/libraw1394/csr.h
/usr/local/myapps/include/libraw1394/ieee1394.h
/usr/local/myapps/include/libraw1394/raw1394.h
/usr/local/myapps/lib/libraw1394.a
/usr/local/myapps/lib/libraw1394.la
/usr/local/myapps/lib/libraw1394.so
/usr/local/myapps/lib/libraw1394.so.11
/usr/local/myapps/lib/libraw1394.so.11.0.1
/usr/local/myapps/lib/pkgconfig/libraw1394.pc

Now, when I try to install libdc1394 which checks for the occurence of libraw, says libraw is not installed. Why the configure script fails to check at the at the path /usr/local/myapps ?

Configuration (libdc1394):

    libraw1394 support (Linux legacy):  Disabled (libraw1394 not found)

What environment variable needs to be set?

II)
I install ffmpeg with prefix as /usr/local/myapps . But after installing it, when I type "/usr/local/myapps/bin/ffmpeg -version" it says libraries such as libavfilter.so.15 not found. I did an strace and found that ffmpeg binary checks the .so files in the paths, /lib64, /usr/lib64 etc and fails. I have to make symlinks to make this work. How to make ffmpeg binary check the libraries at /usr/local/myapps/lib itself?

---------- Post updated at 02:12 PM ---------- Previous update was at 01:55 PM ----------

Got the answer to the first question.
I opened the file /usr/local/myapps/lib/pkgconfig/libraw1394.pc and saw "Libs: -L${libdir}".
I set the LIBS env variable as follows.

LIBS=-L/usr/local/myapps/lib

That solved the issue.

Please help me how to solve FFmpeg issue described above.

---------- Post updated at 03:19 PM ---------- Previous update was at 02:12 PM ----------

Solved!!
I was able to solve the secind issue

Add "/usr/local/myapps/lib" to a new file /etc/ld.so.conf.d/myapps.conf and run the command below.

ldconfig

or you could also set LD_LIBRARY_PATH, but storing it in /etc/ld.so.conf is better -- permanent solution. Glad you worked it out.
Note that you have two different libraries -- static (.a files), that get linked against at the compilation time, and dynamic (.so), that are loaded at runtime. Compiler needs to know location of static libs, when you define the LDFLAGS var; whereas /etc/ld.so.conf, or LD_LIBRARY_PATH store the location of dynamic libs.
Cheers!