unix Library path variables.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting unix Library path variables.
# 1  
Old 06-24-2011
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
# 2  
Old 06-24-2011
For static libraries, set LDFLAGS env var like this:

Code:
LDFLAGS=-L/usr/local/mydir


If you do ./configure --help it will tell you more
# 3  
Old 06-24-2011
Thank you.

I compiled libogg-1.2.2 with ./configure --prefix=/usr/local/myapps --with-pic
It got installed fine.
Code:
[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

Code:
[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
Code:
[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.
Code:
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.
Code:
[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.
Code:
[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.
# 4  
Old 06-24-2011
Quote:
[root@ffmpeg /]# LDFLAGS=-L/usr/local/myapps
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
Code:
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:
Code:
--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:
Code:
./configure --with-ogg=/path/to/ogg

# 5  
Old 06-28-2011
Two questions:

I)

Thank you. I ran these commands.

Code:
[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.
Code:
/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 ?

Code:
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.

Code:
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.
Code:
ldconfig

# 6  
Old 06-28-2011
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!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

AIX full path to socket library

Can somebody help me too identify full path to socket library on AIX? Cannot find anything Thanks for contribution (2 Replies)
Discussion started by: digioleg54
2 Replies

2. Programming

Library/header path for ./configure

Hello, I am always confused about adding library path for ./configure when compiling software under Linux Debian based OS. For example the README of the software tells --with-boost=PATH specify directory for the boost header files --with-mpi=PATH specify prefix directory for... (4 Replies)
Discussion started by: yifangt
4 Replies

3. AIX

Embedding Runtime Search Path into Library on AIX

My product has 2 libraries say "x & y". x depends on y. During the installation of my products package, user will be prompted for his own location to copy my product libraries. Installation will copy libraries "x & y" and create my product specific ENV variable say "MYPATH" pointing to User... (4 Replies)
Discussion started by: erra_krishna
4 Replies

4. Programming

C++ library path

Hello, How to set up the path for downloaded C/C++ libraries (or, header files) so that they can be included like system headers (stdio.h or iostream)? The libraries/headers are from a package containing different folders each has different sets of headers and put in... (1 Reply)
Discussion started by: yifangt
1 Replies

5. UNIX for Advanced & Expert Users

Can't find path for shared library: libintl.sl

Hello, Any inputs about this one? /usr/lib/dld.sl: Can't find path for shared library: libintl.sl /usr/lib/dld.sl: No such file or directory : Core file for 32-bit PA-RISC application : /tmp/usr/local/bin/git saved to /etc/core.git. ABORT instruction (core dumped) bash-4.0# echo... (3 Replies)
Discussion started by: SystemAddict
3 Replies

6. Shell Programming and Scripting

Library on Remote machine or $PATH is not working..

I don't know how to put this. However here is the problem. While executing command remotely on a Unix machine i get an error /usr/lib/hpux32/dld.so: Unable to find library 'libxerces-c.sl.21'. However when i execute the command on the remote machine locally. it works fine. Also i have... (2 Replies)
Discussion started by: suraj.sheikh
2 Replies

7. UNIX for Advanced & Expert Users

library path in linux

Is there something which is an alternative to the variable LD_LIBRARY_PATH? The behaviour of this variable is that the path specified here will be checked before checking usual paths. But I want to have some folders checked for shared libraries after the usual paths. i.e usual paths have to... (3 Replies)
Discussion started by: bbala
3 Replies

8. Shell Programming and Scripting

Setting path for a stand alone library in home directory

Hi all, This is probably a basic question. I had installed a stand-alone library called szip in my home directory, as I don't have the necessary root permission. I tried to set an environment for both include and lib files in my .cshrc script as setenv /home/szip/lib setenv... (3 Replies)
Discussion started by: alamcheril
3 Replies

9. HP-UX

removing library path

Hi Everyone I have written an installer dependant on several shared libraries. I am attempting to strip the full path from these dependant libraries using the chatr command via a script file but am having no success. Running ldd on the intaller exe fails with the following error. Cant open... (4 Replies)
Discussion started by: C3000
4 Replies

10. UNIX for Dummies Questions & Answers

library path

How do you get an application to use an alternate library? Dave:confused: (2 Replies)
Discussion started by: nucca
2 Replies
Login or Register to Ask a Question