Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

question on linking while compilation.

Posted on 2008-10-24
5
Medium Priority
?
343 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

664 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