LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-29-2010, 01:05 PM   #1
lin2winwin
LQ Newbie
 
Registered: Nov 2007
Posts: 26

Rep: Reputation: 15
doubt using libraries in g++ linker


Hi,

I am having some trouble when I try to link my custom libraries to target executables.

There are two libraries

liba
libb

and an executable exec based on main.o

The library libb has some reference to liba. Now if I put the libraries in same directories, I can compile the code as

g++ -o exec main.o liba.a libb.a

But, if I put the libraries in different directories, say d1 and d2, and use the command as

g++ -o exec main.o d1/liba.a d2/libb.a

I get an error as undefined reference to some function in liba. I am not sure if I am missing some thing in linking process.

Also, if libb doesnot refer any functions in liba, there is no error in either of the case.

Please advise...
 
Old 06-29-2010, 01:19 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
"-Ld1 -la -Ld2 -lb"
 
  


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
Static libraries vs shared Libraries catallergy Linux - Newbie 2 03-16-2010 01:30 PM
[SOLVED] cryptic linker error (i really dont like linker errors); smeezekitty Programming 2 09-19-2009 02:21 AM
libraries and linker flags icecubeflower Programming 4 09-08-2009 06:22 PM
Doubt about how a linker builds a memory image funkymunky Programming 4 02-18-2005 11:59 AM
linker error Config Programming 8 06-04-2002 03:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:00 AM.

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