LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to use libunrar.so in my c program? (https://www.linuxquestions.org/questions/programming-9/how-to-use-libunrar-so-in-my-c-program-735199/)

john.daker 06-24-2009 03:17 AM

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.

tronayne 06-25-2009 12:27 PM

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.

john.daker 06-26-2009 05:07 AM

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?

tronayne 06-26-2009 07:27 AM

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.

john.daker 06-29-2009 04:48 AM

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...

tronayne 06-29-2009 06:20 AM

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.


All times are GMT -5. The time now is 03:38 PM.