views:

503

answers:

1

I am trying to use LZMA SDK to compress a file in my program. I have download the SDK but I don't know how to use it. Can anyone tell me what steps I need to take to make this work? Any help would be highly appreciated

I am almost a newbie to C and C++ world

+2  A: 

As a general answer to this question to get any sdk to work, you need to do three things:

  • #include the appropriate headers in your source so that the compiler can check you've used the right functions and the linker knows which symbols you're refering to.
  • Tell the compiler where your header files are. You can do this with gcc using gcc -I/path/to/header/dir.
  • Tell the linker where the libs are that are to be compiled in and to include them. Again, using gcc, you do this with gcc -L/path/to/library/dir and you tell gcc (well, ld) to link to a specific library using gcc -lnamewithoutlibprefix (lowercase l).

As an example for a library I use a lot, MPIR, against the /opt tree, I might compile like this:

gcc -I/opt/include -L/opt/lib -lmpir myprog.c -o myprog

That's just an example and is very Linux-specific. In truth, MPIR is installed in /usr and I don't need to do this, I'm just picking on it by way of example here.

For Windows, take a look at cl /I, and LINK.EXE options.

Of course, you can automate this process under a number of different development environments. Visual Studio, for example, will generate the correct command lines for you if you fill in the right dialog boxes. So I believe will Eclipse and I know Dev/C++ can, too.

Ninefingers
well, is it possible to somehow embed an executable file in my own program?? Cuz there's a command line version of LZMA SDK called 7za.exe and I can use it to compress and decompress files using system() command in my program but I am wondering if I can put it in my own program ..
Milad