LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-29-2009, 10:19 AM   #1
jungle
LQ Newbie
 
Registered: Aug 2004
Posts: 19

Rep: Reputation: 0
gcc dynamic link switches


I am trying to use a shared bzip2 library in a program i'm writing. For the life of me I can't figure out the correct gcc switch to link it in. I've tried pkg-config, but i don't know the name of the .pc file.

is there any rule for these things? i've had this problem before and never managed to find a good solution.

bill
 
Old 05-29-2009, 12:30 PM   #2
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by jungle View Post
For the life of me I can't figure out the correct gcc switch to link it in.
Have you tried passing the "-l" option to GCC when linking?
Code:
# gcc -o <output> <object file names> -lmine
The above will attempt to link "libmine" with the rest of your object files.

You might have to specify the path to the library:
Code:
# gcc -L/path/to/libmine.so -o <output> <object file names> -lmine
NOTE: These examples assume you are trying to link to a shared version of the library.
 
Old 05-29-2009, 01:22 PM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Programming with libbzip2
http://linux.math.tifr.res.in/manual.../manual_3.html

http://www.pelicanprogramming.com/tu...ip2_prog1.html

http://www.opensource.apple.com/sour...text#top-level
Quote :
Programming with libbzip2.
To use any part of the library, you need to #include <bzlib.h>
.....
There is no '.pc ' file for libbzip2(-devel), AFAIK.
.....
 
Old 05-29-2009, 05:38 PM   #4
jungle
LQ Newbie
 
Registered: Aug 2004
Posts: 19

Original Poster
Rep: Reputation: 0
i figured it out. i wasn't completely clear with my first post. i knew that i needed a "-l***" switch, but I didn't know what the ****'s were. I've found out that it's actually the name of the library. it took a while to find out the name of the library. i finally used

Code:
$ rpm -ql bzip2-libs
  /lib/libbz2.so.1
  /lib/libbz2.so.1.0.4
therefore the correct switch was

Code:
gcc -lpng12 -lbz2 prog1.c
i used libpng as well.

bill
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to link dynamic lib from my application amit_pansuria Programming 1 06-09-2007 08:16 PM
Fedora Core 1 dynamic link error yamaduc Linux - Software 2 05-26-2004 07:49 PM
Dynamic link libraries eshwar_ind Programming 1 05-09-2004 11:02 PM
Linux Version of Dynamic Link Libraries paul_eniki Programming 4 02-05-2004 09:25 AM
mysql won't start... dynamic link error SerfurJ Linux - Software 2 11-20-2003 10:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration