LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-22-2013, 10:34 AM   #1
gavincangan
LQ Newbie
 
Registered: Jun 2013
Posts: 4

Rep: Reputation: Disabled
Question Library linking error


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!!
 
Old 06-22-2013, 10:46 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,880
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
You should have a file called libjack.so
Normally it comes from package 'libjack-devel' (or similiar), but you might try this too:

Code:
cd /wherever/it/is
ln -s libjacket.so.0 libjacket.so
Note: /usr/bin is the wrong place for a shared lib, it should go to /usr/lib or /usr/local/lib
 
Old 06-22-2013, 10:51 AM   #3
gavincangan
LQ Newbie
 
Registered: Jun 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
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
 
Old 06-22-2013, 10:52 AM   #4
gavincangan
LQ Newbie
 
Registered: Jun 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
I tried the command. But I still get the same error!
Btw what does that command do??
 
Old 06-22-2013, 11:28 AM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,517

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Jack provides :
/usr/lib/libjackserver.so@ /usr/lib/libjack.so@
/usr/lib/libjackserver.so.0@ /usr/lib/libjack.so.0@
/usr/lib/libjackserver.so.0.1.0 /usr/lib/libjack.so.0.1.0

Or : The files could be in /usr/local/lib/,
if it is a manual install.

-
 
Old 06-22-2013, 11:29 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,880
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
1. That's what 'man gcc' and 'man ld' is good for. Also read this: http://gcc.gnu.org/onlinedocs/gcc-4....l#Link-Options
2. Read 'man ln', and this: http://en.wikipedia.org/wiki/Symbolic_link
 
Old 06-22-2013, 04:30 PM   #7
gavincangan
LQ Newbie
 
Registered: Jun 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Question Library linking in

I read the man page about ln. I did understand that it was a link. But that still hasn't solved my problem.

Code:
[gavincangan@localhost ~]$ su --login
Password: 
[root@localhost ~]# cd /home/gavincangan/portaudio/portaudio/build/msvc/
[root@localhost msvc]# echo $LD_LIBRARY_PATH

[root@localhost msvc]# export LD_LIBRARY_PATH=/usr/bin
[root@localhost msvc]# echo $LD_LIBRARY_PATH
/usr/bin
[root@localhost msvc]# echo $PATH
/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost msvc]# gcc -lrt -lasound -ljack -lpthread -o crosscorr paex_record.c libportaudio.a
/bin/ld: cannot find -ljack
collect2: error: ld returned 1 exit status
[root@localhost msvc]# export LDFLAGS="-rpath /usr/bin/libjack.so.0 " $LDFLAGS  
[root@localhost msvc]# gcc -lrt -lasound -ljack -lpthread -o crosscorr paex_record.c libportaudio.a
/bin/ld: cannot find -ljack
collect2: error: ld returned 1 exit status
[root@localhost msvc]# echo $LD_FLAGS

[root@localhost msvc]# export LDFLAGS="-rpath /usr/bin" $LDFLAGS  
-bash: export: `-rpath': not a valid identifier
-bash: export: `/usr/bin/libjack.so.0': not a valid identifier
[root@localhost msvc]# export LDFLAGS="-rpath /usr/bin " $LDFLAGS  
-bash: export: `-rpath': not a valid identifier
-bash: export: `/usr/bin': not a valid identifier
[root@localhost msvc]# export LDFLAGS="-rpath /usr/bin/libjack.so.0 " $LDFLAGS  
-bash: export: `-rpath': not a valid identifier
-bash: export: `/usr/bin': not a valid identifier
[root@localhost msvc]# cd /usr/bin/
[root@localhost bin]# ln -s libjack.so.0 libjack.so
[root@localhost bin]# cd /home/gavincangan/portaudio/portaudio/build/msvc/
[root@localhost msvc]# gcc -lrt -lasound -ljack -lpthread -o crosscorr paex_record.c libportaudio.a
/bin/ld: cannot find -ljack
collect2: error: ld returned 1 exit status
[root@localhost msvc]# man ln
Above is my terminal log. Please help me out with this.

I installed JACK using yum. In my comp I used find command and it found libjack.so and libjack.so.0 in /usr/bin
 
Old 06-23-2013, 02:58 AM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,517

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Post # 7 .
Quote:
[root@localhost msvc]# export LD_LIBRARY_PATH=/usr/bin
! 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


Quote:
[root@localhost bin]# ln -s libjack.so.0 libjack.so
Why ? There shouldn't be any libs in /usr/bin/.
Please test with $ ls -l /usr/bin/ | grep lib

-

Last edited by knudfl; 06-23-2013 at 04:05 AM.
 
Old 06-23-2013, 03:14 AM   #9
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,880
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
To OP: Where these commands came from? They make no sense at all.

For a start, try to determine what OS/distribution do you have.

Last edited by NevemTeve; 06-23-2013 at 03:16 AM.
 
1 members found this post helpful.
Old 06-26-2013, 10:18 AM   #10
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Linker options:
Code:
-lsomelibrary and -L /some/directory
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.

--- rod.

Last edited by theNbomr; 06-26-2013 at 10:24 AM.
 
Old 06-26-2013, 07:47 PM   #11
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by gavincangan View Post
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.

Kevin Barry

Last edited by ta0kira; 06-26-2013 at 07:59 PM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Linking static library INTO dynamic library miguelg Programming 6 12-10-2012 09:56 AM
installing Pixie renderer x64 linking shared library error obstinatesnooper Linux - Software 0 06-24-2009 07:55 AM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 PM
strange linking error -- can not find shared library George2 Programming 1 07-10-2006 11:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration