Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-15-2009, 08:49 PM   #1
Al Effendi
LQ Newbie
Registered: Dec 2003
Posts: 8

Rep: Reputation: 0
link multiple libraries


Thanks in advance

how can i link multiple libraries not diff. versions
eg. C library + others

Appreciate help

Old 03-15-2009, 09:00 PM   #2
Senior Member
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 50
I am not sure what you mean by "link". Like in linking a program to a .so/.la file?

In that case, assuming you are using gcc, you just send the -l flag as many times you want:

gcc file.cpp -o program -lmath -lpthread -lsomeotherlibrary
1 members found this post helpful.
Old 03-15-2009, 09:59 PM   #3
Registered: Mar 2009
Distribution: Fedora, Slackware
Posts: 104

Rep: Reputation: 21
There is a difference between linking static libraries and shared libraries. Here is a sample from a Makefile:

INCS=-I/usr/include/GL -I.
LIBS=-lm -lGL -lGLU
AUXLIBS=./libaux.a ./libtk.a

gcc -c openglbk_0/cube.c $(INCS)
gcc -o cube cube.o $(AUXLIBS) $(LIBS)
@echo "done cube build"
Static lib usually end with .a, shared libs tend to use the .so naming convention. Shared libs are prefixed with '-l', and a libfile name 'libGL' is used as '-lGL' (note: 'lib' is omitted in the usage). Static libs are simply defined by their pathname.


Linux Archive

Last edited by JaksoDebr; 04-02-2009 at 05:10 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to link external c++ libraries? Asuralm Programming 3 11-06-2007 08:43 AM
How to link libraries with g++ [KIA]aze Programming 1 04-13-2007 03:38 AM
link non-default libraries in KDevelop?? TLV Programming 3 12-14-2004 11:25 AM
Dynamic link libraries eshwar_ind Programming 1 05-09-2004 11:02 PM
gaim trying to link static and shared libraries rose_bud4201 Linux - Software 0 09-28-2003 12:27 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:14 AM.

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