Solved

question on linking while compilation.

Posted on 2008-10-24
5
311 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
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.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

930 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

16 Experts available now in Live!

Get 1:1 Help Now