LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-24-2009, 03:17 AM   #1
john.daker
Member
 
Registered: Jul 2008
Posts: 33

Rep: Reputation: 15
How to use libunrar.so in my c program?


Deal all,
I've download unrarsrc-3.9.4.tar.gz and make a libunrar.so lib, and I want to use it in my c code, I can hardly find any api docs using google, how to use libunrar.so in my c program?

Thanks.
 
Old 06-25-2009, 12:27 PM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
When you made the library; e.g., with make, did you also (as super user) execute make install? Did the library get install in /usr/local/lib? Do you have a file, ld.so.conf somewhere in your /etc directory (or a sub-directory of /etc? If so, is there a line in that file like this:
Code:
/usr/local/lib
there may be other lines, too
If so, when you compile a C program, simply...
Code:
cc -o prog prog.c -lunrar
If you did not install the library somewhere, then you would
Code:
cc -o prog prog.c -LPATH_TO_DIRECTORY -lunrar
where PATH_TO_DIRECTORY is the path from where you are to the directory that contains the file libunrar.so.

The above is purposely simplified; it's probable that you'll need to include a header file, possibly ubnrar.h, that contains the definitions of the various functions contained in that library -- wouldn't be a bad idea to read the documentation that came with the unrarsrc package (README, manual pages, etc.).

Hope this helps some.

Last edited by tronayne; 06-25-2009 at 12:28 PM.
 
Old 06-26-2009, 05:07 AM   #3
john.daker
Member
 
Registered: Jul 2008
Posts: 33

Original Poster
Rep: Reputation: 15
Thanks, but what I mean is that I dont know how to use functions the libunrar.so provide, is there any api docs for libunrar?
 
Old 06-26-2009, 07:27 AM   #4
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
I've just spent about 30 minutes bouncing around looking for documentation for this thing... and, well, there just doesn't seem to be any. Odd, that. The unrarlib home site, http://www.unrarlib.org, tells us that the project is inactive (since October 2007), provides a bunch of links (none of which appear to document how to actually use the thing), and I'm at a loss.

I did download unrarsrc-3.7.8.tar.gz and did make -f makefile.unix which resulted in unrar (not a library, an executable utility). Executing that as unrar -help produces a listing of all the command line options -- maybe that's what you're looking for?

Best of luck with it.

Last edited by tronayne; 06-26-2009 at 07:36 AM.
 
Old 06-29-2009, 04:48 AM   #5
john.daker
Member
 
Registered: Jul 2008
Posts: 33

Original Poster
Rep: Reputation: 15
Thanks for your work...
I use `make lib -f makefile.unix`, and got a `libunrar.so`, just dont know
how to call the functions libunrar.so provide...
 
Old 06-29-2009, 06:20 AM   #6
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
After I couldn't find anything, anywhere that looked anything like documentation, I scanned through all the source code to see if there were any comments in the files describing what the functions was supposed to do and the like; nuthin, nowhere, nohow. From what I could gather, RAR appears to be a windows-only thing that's been ported to other systems (I think once in the last 10 years somebody has sent me a RAR file and I had to dig around to find unrar so I could unpack the thing). I looks to me like if you just make -f makefile.unix you'll get the utility, unrar, and you can figure out how to use it from the help; there's no man page, no documentation, but there is that utility. I just doesn't look like RAR is a going concern any more and it might be beating a dead horse.

Hope this helps some.
 
  


Reply



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
libunrar - segfault inside library elitecodex Programming 1 06-24-2008 05:01 AM
Simple C++ Program: Program Compiles But Won't Run (Segmentation Fault) violagirl23 Programming 3 01-09-2008 12:09 AM
Total recovery: Which program? ghost4linux, YaST2? Best drive imaging program? lagu2653 Linux - Software 1 06-20-2005 01:44 PM
Key bindings program (custom pasting, program execution, etc.) jrdioko Linux - Software 2 02-05-2005 09:09 PM
Gtk-Warning but program still works... I close konsole, program closes Laptop2250 Linux - Software 2 11-14-2003 11:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:48 AM.

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