LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 01-02-2006, 09:31 PM   #1
stonehurstX11
Member
 
Registered: Dec 2003
Location: New Jersey, USA
Distribution: Ubuntu 10.04
Posts: 120

Rep: Reputation: 15
Linking with a library


Say I have a shared library object in a local directory, and I want to include that library when I'm linking my program. What flags would I have to pass to ld for this to happen?

For example, say I have somelib.la in my build directory. How would I tell my linker to include that particular shared library object?

Thanks in advance!
 
Old 01-02-2006, 10:17 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Use the flag -lsomelib (the library may have to have a .a or .so extension -- I'm not sure if it will bick up .la extensions). The current directory should be in the library search path -- if not you'll need to add the path to the LD_LIBRARY_PATH environment variable or use the -L /directory/containing/library command line option.
 
Old 01-02-2006, 11:25 PM   #3
stonehurstX11
Member
 
Registered: Dec 2003
Location: New Jersey, USA
Distribution: Ubuntu 10.04
Posts: 120

Original Poster
Rep: Reputation: 15
I tried what you suggested, but my linker is still complaining that it can't find the library.

Here is the command I'm executing:
Code:
g++ tb.o trackball.o gldemo.o -o GLdemo -I/usr/include/SDL -L/usr/X11R6/lib -lX11 -lglut -lGL -lGLU -lm -L/home/mike/gl/unix/demo -llibftgl
I'm not sure if I'm even doing this correctly, but the library object is located at /home/mike/gl/unix/demo/libftgl.la. I tried renaming it to libftgl.a, but that didn't work either.
 
Old 01-02-2006, 11:47 PM   #4
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 52
like usual we have to play detective so here come the questions

font library ftgl
where did you two meet
did you install it ?
when did you see it last
do you know where the library is now ? libftgl.so.0

.la files are just text junk not real libraries
has the library come to no good in your hands ?
you can admit it -- we know you didn't mean to hurt it.
 
Old 01-04-2006, 05:07 PM   #5
stonehurstX11
Member
 
Registered: Dec 2003
Location: New Jersey, USA
Distribution: Ubuntu 10.04
Posts: 120

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by foo_bar_foo
like usual we have to play detective so here come the questions

font library ftgl
where did you two meet
did you install it ?
when did you see it last
do you know where the library is now ? libftgl.so.0

.la files are just text junk not real libraries
has the library come to no good in your hands ?
you can admit it -- we know you didn't mean to hurt it.
Sorry for being so vague with my post. :P
Anyways, it turned out that I indeed did not install the library, and shortly after doing so, I can finally link successfully.

Thanks!
 
  


Reply


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
Still library linking problem The_Nerd Programming 19 05-20-2004 05:08 PM
library linking question. shaggz Linux - General 1 04-26-2004 12:22 AM
linking own library bobby2k3 Programming 2 10-20-2003 11:36 AM
Help Linking Library!! Please!! Musikolo Linux - Software 1 07-24-2003 04:16 PM
linking library simonissa Linux - Software 2 05-21-2003 10:41 AM


All times are GMT -5. The time now is 05:11 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration