TestDisk Compilation - CGSecurity
Keywords: TestDisk Compilation,Compile DOS,Compile Linux,Compile Mac OS X,Compile Win,Linux to PPC Darwin Cross Compiler,TestDisk,TestDisk Compilación,TestDisk Compilation FR,TestDisk kompilieren,Компиляция TestDisk

# TestDisk Compilation

### From CGSecurity

english version deutsche Version versión español version française Русская версия

This document explains how to compile TestDisk and PhotoRec.

## System specific notes

### DOS

TestDisk & PhotoRec can compiled for DOS/Win9x using DJGPP. Read DOS for more information.

### Mac OS X

To compile TestDisk & PhotoRec, install `Apple Development Kit` from Mac OS X installation DVD. See Mac OS X for additional notes.

### Linux

- Debian, Ubuntu: `apt-get install build-essential e2fslibs-dev libncurses5-dev libncursesw5-dev libntfs-dev libjpeg62-dev libreiserfs0.3-dev uuid-dev zlib1g-dev`
- Fedora, RedHat Enterprise, CentOS: `yum install ncurses-devel e2fsprogs-devel libjpeg-devel ntfsprogs-devel libewf-devel zlib-devel`
- Mandriva: `urpmi ncurses-devel e2fsprogs-devel jpeg-devel libntfs-devel zlib-devel openssl-devel libewf-devel`
- OpenSuse: install `ncurses-devel e2fsprogs-devel libjpeg-devel ntfsprogs-devel zlib-devel openssl-devel libreiserfs-devel libuuid-devel`

Read Compile Linux for more information.

### Windows

Use the free C/C++ Cygwin compiler to produce Windows version (Windows NT 4/Windows 2000/XP/2003/Vista...).
It's also possible to use MinGW compiler but some functionalities/libraries may be missing. Read Compile Win for additional details.

## Libraries

- libncurses - Required, TestDisk and PhotoRec use a text user interface, Ncurses library and development files must be available.
- Ext2fs library - Optional, used by TestDisk to list files from ext2/ext3 partition and by PhotoRec to be able to carve the free space from an ext2/ext3 partition instead of the whole partition
- EWF library - Optional, TestDisk and PhotoRec use it to access Expert Witness Compression Format files (ie Encase files)
- Iconv - Optional, used to handle unicode filenames
- Jpeg library - Optional, used by PhotoRec to improved JPEG recovery rate
- NTFS library - Optional, used by TestDisk to list files from NTFS partition
- openssl library - Needed if EWF library is used to handle crypto
- Reiserfs library - Optional, used by TestDisk to list files from reiserfs partition
- zlib library - Optional, used by PhotoRec to decompress gzipped content

### ncurses Library

Ncurses library is usually installed with your OS, so you don't need to compile it yourself. If ncursesw is available, TestDisk and PhotoRec will use it to display unicode chars.

### Ext2fs Library

Ext2fs library is usually installed with your OS, so you don't need to compile it yourself. Otherwise get latest version of e2fsprogs at e2fsprogs.sf.net

    tar xzf e2fsprogs-1.38.tgz
    cd e2fsprogs-1.38
    ./configure --with-cc=gcc
    make libs
    make install

### EWF library

EWF library source code can be downloaded from www.uitwisselplatform.nl/projects/libewf/. Note that it requires openssl and zlib to compile and run sucessfully.

    tar xzf libewf-beta-20070408.tar.gz
    cd libewf-20070408
    ./configure
    make lib
    make install

### Iconv library

On most plateform, iconv functions are integrated in libc, so no additional library is needed. Under Windows, a libiconv package is available on cygwin website but as cygwin doesn't handle unicode filename currently, unofficial utf8-cygwin dll should be used instead, A libiconv package is available for DOS/djgpp but it's useless as the OS doesn't support unicode filename.

### Jpeg library

Libjpeg library is usually installed with your OS, so you don't need to compile it yourself. Otherwise download libjpeg source from ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz

    tar xzf jpegsrc.v6b.tar.gz
    cd jpeg-6b
    ./configure --enable-shared --enable-static
    make
    sudo make install

Mac OS X 10.3 ships with GNU libtool, albeit under a slightly different name, glibtool. You may have to run

    ln -s `which glibtool` ./libtool

### How to compile ntfsprogs

Get the latest version of ntfsprogs from linux-ntfs.sf.net

    tar xzf ntfsprogs-1.13.0.tar.gz
    cd ntfsprogs-1.13.0
    ./configure
    make libs
    make install

To get a working version under NT 4, use `configure --disable-default-device-io-ops` because SetFilePointerEx used by win32_io.c is not exported by NT 4 DLL.

### ReiserFS Library

Get progsreiserfs-0.3.1-rc8.tar.gz at reiserfs.osdn.org.ua

    tar xzf progsreiserfs-*.tar.gz
    cd progreiserfs-0.3.1-rc8
    ./configure --disable-nls --disable-Werror
    make
    make install

## How to compile TestDisk

### Standard method

To compile TestDisk and PhotoRec, run

    ./configure
    make

You may need to specify parameters to configure, see configure --help.
Example:

    ./configure
    --with-reiserfs-lib=/home/kmaster/perso/testdisk-5.2/progsreiserfs-0.3.1-rc8/libreiserfs/.libs/
    --with-reiserfs-includes=/home/kmaster/perso/testdisk-5.2/progsreiserfs-0.3.1-rc8/include/
    --with-ntfs-lib=/home/kmaster/perso/testdisk-5.2/ntfsprogs-1.8.5/libntfs/.libs/
    --with-ntfs-includes=/home/kmaster/perso/testdisk-5.2/ntfsprogs-1.8.5/include/
    --with-ext2fs-lib=/home/kmaster/perso/testdisk-5.2/e2fsprogs-1.34/lib
    --with-ext2fs-includes=/home/kmaster/perso/testdisk-5.2/e2fsprogs-1.34/lib

### Static version

If you need to run the binary on systems that lack one of the previous libraries, create a static binary with

    make static

### Static compressed binary

If you need a small binary for binary distribution, get the UPX packer at upx.sf.net and run

    strip src/testdisk src/photorec
    upx src/testdisk src/photorec

Note that Linux UPX needs to decompress program files before running, and it will request some space on /tmp to do this. The running executable must be allowed in this directory (mount -o remount,exec /tmp).

## Cross-compilation

- Linux to PowerPC Darwin/Mac OS X cross-compiler

Return to TestDisk page

Category: Data Recovery

##### Data Recovery

- TestDisk
- PhotoRec
- download