Solved

question on linking while compilation.

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

752 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