ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to run a program that uses two libraries, PortAudio and kissFFT. I got an example program online written in C. But when I try to compile it using gcc compiler, I keep getting the error -ljack is missing.
I've installed JACK and I've added the path containing the file libjack.so.0 to $PATH and $LD_LIBRARY_PATH.
I also used the below command line tip I found online.
export LDFLAGS=" -rpath /usr/bin/libjack.so.0 " $LDFLAGS
But I still keep getting this error. Please help me out!!
Could someone please explain to me the steps required to compile a program including library linking.
The usage of -l and -L switches especially.
I'm greatly confused by this!
Last edited by gavincangan; 06-22-2013 at 11:00 AM.
Reason: Repetition by mistake
! Please read post #2 : No libraries in /usr/bin/ !
Besides that : Don't use root for those user commands.
Root is for administrative tasks only. Export, make are user commands.
Also : May be you didn't install the jack development files ? ?
Which OS are you using ?
Debian style : # apt-get install libjack-jackd2-dev
Redhat style : # yum install jack-audio-connection-kit-devel
The '-l' option names a library to link to the executable object module. The name of the library immediately follows the 'l' and does not include the conventional 'lib' filename prefix nor the '.so' suffix. So, for example, to link a motif library named 'libXm.so', you would use the linker option '-lXm'.
Having been told what libraries to link, the linker needs also to know where to look for libraries. The '-L' option takes one directory name as an argument, and the linker will add the specified directory to it's list of places to look for libraries. The directory name argument is not specific to any particular library, so does not associate with any particular '-l' option.
The resulting executable object module will still need to be able to find the shared object library at runtime, and that is the purpose of $LD_LIBRARY_PATH and/or /etc/ld.so.conf. It allows the linking loader to find the libraries against which the runtime binary was linked. Static linking obviates the need for these, at the expense of drastically inflated object module size.
I also used the below command line tip I found online.
export LDFLAGS=" -rpath /usr/bin/libjack.so.0 " $LDFLAGS
But I still keep getting this error. Please help me out!!
-rpath only helps at run-time. It hard-codes an additional library path (e.g. /usr/libexec/yourapp) into a library or executable. It's generally used if you use -L when linking but plan to move (or leave) the dependency somewhere that's not a standard location, such as when you're building both a library and an executable during make and plan to move them both during make install. You would use -rpath-link to simulate a different -rpath for the purposes of resolving dependencies of dependencies.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.