UnixCompile

From RetroShare Wiki

Jump to: navigation, search

This documents how to compile the latest sources from RetroShare subversion repository.

Contents

Directory layout

This article sticks to the following scheme:

Directory
~ Your home folder
~/src/miniupnpc-x.y miniupnpc directory
~/src/openssl-x.y.z openssl directory (Optional)
~/src/libgpg-error-x.y Libgpg-error directory
~/src/gpgme-x.y.z GPGME directory
~/src/retroshare SVN checkout folder
~/src/retroshare/libretroshare libretroshare
~/src/retroshare/retroshare-gui Qt4 Retroshare GUI
~/lib All the libraries required by Retroshare GUI (libssl.a, libcrypto.a, libretroshare.a,...)


Build dependicies

Needed Packages for compiling Retroshare:

  • libqt4-dev (Qt 4.4.x or newer)
  • g++
$ sudo apt-get install libqt4-dev g++

You have installed your Linux fresh? then use this Packages:

$ sudo apt-get install build-essential qt4-dev-tools subversion

Build prerequisite libraries

Build miniupnpc - mini UPnP client

If your OS already has miniupnp client as a package, you can skip this step.

Download miniupnp from http://miniupnp.free.fr/. You need the client distribution, not MiniUPNP daemon. Compatibility with different miniupnpc version: 1.3 - official version bundled with RetroShare.

Build

$ cd ~/src
$ wget http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.3.tar.gz
$ tar -xzvf miniupnpc-1.3.tar.gz
$ cd miniupnpc-1.3
$ make

Testing
Test miniupnpc by running upnpc-static utility it builds. If upnpc is able to find your router (UPNP device), it will show a list of mappings on it:

$ ./upnpc-static -l
upnpc : miniupnpc library test client. (c) 2006-2008 Thomas Bernard
...
ExternalIPAddress = 1.2.3.4
0 UDP 40950->192.168.1.3:40950 'Azureus UPnP 50950 UDP' ''
1 TCP 20950->192.168.1.3:20950 'Azureus UPnP 50950 TCP' ''
...

Copy miniupnpc library to the library folder:

$ cp libminiupnpc.a ~/lib


Build Libgpg-error and GPGME

If your OS already has gpg-error/gpgme as a package, you can skip this step.

Download Libgpg-error from http://www.gnupg.org.

Build

$ cd ~/src
$ wget ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.7.tar.bz2
$ tar -xzvf libgpg-error-1.7.tar.bz2
$ cd libgpg-error-1.7
$ ./configure
$ make
$ make install

Download GPGME from http://www.gnupg.org.

Build

$ cd ~/src
$ wget ftp://ftp.gnupg.org/gcrypt/gpgme/gpgme-1.1.8.tar.bz2
$ tar -xzvf gpgme-1.1.8.tar.bz2
$ cd gpgme-1.1.8
$ ./configure
$ make
$ make install

Build openssl (optional)

RetroShare uses openssl SSL library . You can use your own installed OpenSSL which is installed on your Linux System or you compile latest stabile for RetroShare.

Building openssl-0.9.8k (optional)

You can download stabile openssl sources from http://www.openssl.org/.

Build
Important: do not run make install as it may overwrite the system openssl and could break your system

$ cd ~/src
$ wget http://www.openssl.org/source/openssl-0.9.8k.tar.gz
$ tar -xzvf openssl-0.9.8k.tar.tgz
$ cd openssl-0.9.8k
$ ./configure 
$ make
...

Copy libssl and libcrypto to the library folder:

$ cp libssl.a ~/lib
$ cp libcrypto.a ~/lib


Build RetroShare

Obtain latest retroshare sources from SVN

Source release is quite old at the moment and it is a good idea to obtain sources from subversion:

$ cd ~/src
$ svn co https://retroshare.svn.sourceforge.net/svnroot/retroshare/trunk retroshare
...
Checked out revision 1495.

This should create ~/src/retroshare/libretroshare, ~/src/retroshare/retroshare-gui etc.

Build libretroshare

    • Optional Change SSL_DIR to point to your openssl-0.9.8k directory( default dir is SSL_DIR = /usr/include/openssl ).

Check that SSL_DIR really points to openssl-0.9.8k folder (optional).
Check that GPG_ERROR_DIR really points to libgpg-error-1.7 folder.
Check that GPGME_DIR really points to gpgme-1.1.8 folder,
because it's easy to have one "../" too much:

libtretroshare.pro:

DEFINES *= MINIUPNPC_VERSION=13

UPNPC_DIR = ../../../../miniupnpc-1.3
GPG_ERROR_DIR = ../../../../libgpg-error-1.7
GPGME_DIR  = ../../../../gpgme-1.1.8

################################# Linux ##########################################
linux-g++ {
	OBJECTS_DIR = temp/linux-g++/obj
	DESTDIR = lib.linux-g++
	QMAKE_CXXFLAGS *= -Wall 
	QMAKE_CC = g++
	SSL_DIR = /usr/include/openssl
	CONFIG += version_detail_bash_script
}
linux-g++-64 {
	OBJECTS_DIR = temp/linux-g++-64/obj
	DESTDIR = lib.linux-g++-64
	QMAKE_CXXFLAGS *= -Wall 
	QMAKE_CC = g++
        SSL_DIR = /usr/include/openssl
	CONFIG += version_detail_bash_script
}
    • Change UPNPC_DIR to point to your miniupnp directory
    • Change DEFINES += -DMINIUPNPC_VERSION=13 to match your miniupnpc version (10 for 1.0 or 12 for 1.2 13 for 1.3)
  • 64bit Notice:
    • If youre using a 64bit Linux you must remove the -marchi=686 option in this line: BIOCFLAGS = -I $(SSL_DIR)/include ${DEFINES} -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DOPENSSL_NO_KRB5 -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -march=i686 -Wall -DSHA1_ASM -DMD5_ASM -DRMD160_ASM


Build

$ cd ~/src/retroshare/libretroshare/src
$ qmake
$ make
..
$  cp lib/libretroshare.a ~/lib




Build retroshare GUI

Check
Check that all the libraries are compiled and path to libraries folder in RetroShare.pro is correct:

$ cd ~/src/retroshare/retroshare-gui/src
$ ls ../../../../lib   <--- that's my -L path from RetroShare.pro
libcrypto.a libminiupnpc.a  
libretroshare.a  libssl.a

If some libraries are not there, you probably forgot to copy them. If path to lib is wrong, correct it in RetroShare.pro.

Build Run

$ cd ~/src/retroshare/retroshare-gui/src
$ qmake
$ make


Troubleshooting
Most common troubles are missing includes

  • if gcc says "find" is unknown (no matching function for call to 'find(std::_List_iterator...), add #include <algorithm>
  • if std::bad_cast is unknown, add #include <typeinfo>
  • If on the link stage you receive lot of undefined reference errors ("undefined reference to `generate_xpgp' etc), all mentioning pgp: it's likely that you link to standard libssl.a and libcrypto.a instead of openssl-xpgp versions. This can happen if libraries are not found: linker silently uses standard libraries instead, because openssl is installed on all systems.


If compilation was successful, you should be able to start RetroShare executable:

$ ./RetroShare
Personal tools
wiki