Solved

question on linking while compilation.

Posted on 2008-10-24
5
302 Views
Last Modified: 2010-08-05
hello group,

I'm using a library to handle CSV file so currently I'm linking it by passing the complete path to gcc. But for a different library I just use -l switch and works fine.
What is the difference? is it because the library is not in the path or .... ?

Currently I'm running gcc as:
$ gcc   /usr/lib/libcsv.a -o  target_file  src.c

What should I do to be able run it as:
$ gcc   -llibcsv.a -o  target_file  src.c

Thanks,
ak


0
Comment
Question by:akohan
5 Comments
 
LVL 45

Expert Comment

by:sunnycoder
Comment Utility
Hello akohan,

The path to other library is known to your linker ...
man ldconfig
man ld.so.conf

Regards,

sunnycoder
0
 
LVL 53

Expert Comment

by:Infinity08
Comment Utility
Note that you can add a path to the linker search path using -L

http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Directory-Options.html#index-iquote-884
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 125 total points
Comment Utility
The usual syntax for the -l flag is (in your case) '-lcsv', i.e. omit the lib... and the .a parts.
wmp
0
 

Author Comment

by:akohan
Comment Utility

Hi Woolmilkporc,

Thanks that works! Also, thanks to other for your links and commments.


regards,
ak
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
You're welcome! Glad I could help you.
BR Norbert
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now