1

I am trying to maintain file history on a server from a client and I have thought of using xdelta for it. There is almost no help online for using xdelta. I gathered a few bits and pieces of code and tried to run it in order to understand it myself but the compiler gives the following error:

fatal error: xdelta3.h: No such file or directory

I have installed xdelta3 using apt-get as well as by downloading .tar from the website.

Here's the header files I included:

#include <xdelta3.h>
#include <xdelta3-main.h>

Any ideas as to what the header files for xdelta are? It will be appreciated if you could also provide some links for learning how to use xdelta since the documentation is insufficient for me.

Chandan
  • 146
  • 2
  • 15

1 Answers1

1

First of all, be sure that you have -dev package installed as well. On my Debian system I did:

$ sudo apt-get install libxdelta2-dev

Now you should be able to use those xdelta headers. But they can have different naming than you use. You can check it this way:

$ dpkg -L libxdelta2-dev | grep include

For me shows:

/usr/include/edsio_edsio.h
/usr/include/edsio.h
/usr/include/xd_edsio.h
/usr/include/xdelta.h

So you can see that in this case I should use xdelta.h header, no xdelta3.h. Try the same dpkg -L command with your -dev package.

If you have different version of xdelta*-dev package, check output of this command:

pkg-config --list-all | grep delta

For me output is empty, but if you have something like libxdelta in output, be sure to compile your application with these options:

$ gcc $(pkg-config --cflags --libs libxdelta) main.c

UPDATE 1

As for the linking issue you have. I guess you are using gcc, so it automatically uses correct linker for you. The thing is, you should provide library name, which you want to link your program with, as a linker option.

First you should figure out your actual library name:

$ ls -1 /usr/lib | grep xdelta | grep so

You will see something like this:

libxdelta.so
libxdelta.so.2
libxdelta.so.2.0.0

Now you know your library name: it's part of library file name between lib and .so, in this case library name is xdelta.

Now you can link your program with it, using -l option:

$ gcc -lxdelta main.c

You may be also needed to specify path to xdelta library, if it's not a standard one (like /usr/lib/):

$ gcc -L/your/path/to/xdelta/ -lxdelta main.c

UPDATE 2

How to build and use xdelta3.

  1. Obtain sources:

    cd /tmp
    wget https://xdelta.googlecode.com/files/xdelta3-3.0.8.tar.xz
    tar xJvf xdelta3-3.0.8.tar.xz 
    cd xdelta3-3.0.8/
    
  2. Build and install:

    ./configure
    make
    sudo make install
    
  3. Check if it works:

    cd examples/
    make clean
    make encode_decode_test
    ./encode_decode_test
    

If everything is fine, you should have executable file "encode_decode_test". It's example uses xdelta3. Now you can build your program the same way. See "Makefile" file inside of "examples" directory to get a clue how to build your program. Note that there is no libraries involved now.

Sam Protsenko
  • 12,371
  • 2
  • 53
  • 69
  • Thanks! I installed the -dev package too. All the other outputs are same as yours. But while compiling, I get an "undefined reference to " error. I guess this might be a linker error. What is the linker that I should use? – Chandan Mar 01 '15 at 21:58
  • I have added the answer for your question above, see **UPDATE** section. – Sam Protsenko Mar 01 '15 at 22:34
  • I have the given files in /usr/lib. g++ -lxdelta main.c or gcc -lxdelta main.c still does not work. The "undefined reference to..." problem still exists. – Chandan Mar 01 '15 at 23:11
  • Please provide full error string and also which version of xdelta library you are using (if it's from Ubuntu repository, provide Ubuntu version and library package name). – Sam Protsenko Mar 01 '15 at 23:16
  • /tmp/ccbWjchy.o: In function `main': xd3-1.cpp:(.text+0x7e): undefined reference to `xd3_config_stream(_xd3_stream*, _xd3_config*)' collect2: error: ld returned 1 exit status..... I am using Ubuntu 13.10; xdelta version is 1.1.3 – Chandan Mar 01 '15 at 23:27
  • Ok, the problem is next: you have installed library and headers for **xdelta2**, but in your code you are trying to use **xdelta3** API. So linker can't find `xd3_config_stream` function in your xdelta library, because your library basically doesn't have it. You need to install **xdelta3** library and headers first (and don't forget to remove **xdelta2** library, just in case). You should either look for xdelta3 package or build it manually. – Sam Protsenko Mar 01 '15 at 23:45