Solved

question on linking while compilation.

Posted on 2008-10-24
5
329 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
ID: 22794033
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
ID: 22794077
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
ID: 22794100
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
ID: 22798741

Hi Woolmilkporc,

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


regards,
ak
0
 
LVL 68

Expert Comment

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

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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 …
Fine Tune your automatic Updates for Ubuntu / Debian
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

830 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