Monday, July 22, 2013

Installing Qt 5.1 on a virtual CentOs 6.4 server

1. Get the latest VirtualBox software from https://www.virtualbox.org/wiki/Downloads

2. Get CentOS 6.4 DVDs or ISO files from the Internet, e.g.here:
http://mirrors.usc.edu/pub/linux/distributions/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-bin-DVD1.iso and here http://mirrors.usc.edu/pub/linux/distributions/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-bin-DVD2.iso

Install CentOS VM with 4-5GB RAM, 4-6 CPUs and 40GB HD.

System->Administartion->Software Update - install the updates
Devices->Install Guest Additions
System->Preferences-Screen Saver: unselect "Activate when idle"

Restart the VM


#If the VM HD needed to be later resized
#>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd
#"C:\Users\david_000\VirtualBox VMs\AdEx2 CentOS 6.4_ QT 5.1\AdEx2 CentOS 6.4_ QT 5.1.vdi" --resize 32768

3. Build the latest GCC from the sources, e.g. from http://gcc.cybermirror.org/releases/gcc-4.8.1
mkdir ~/tmp
cd ~/tmp

tar -jxvf ~/Downloads/gcc-4.8.1.tar.bz2

cd gcc-4.8.1
./contrib/download_prerequisites
mkdir gcc-build
cd gcc-build
sudo ../configure --disable-multilib
sudo make
sudo make install



4. Edit ~/.bash_profile adding there

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64
export LD_LIBRARY_PATH


#save & close the file, init the environment in your terminal
source ~/.bash_profile


5. Download Qt
su

#install missing gstreamer packages, if any
yum install 'pkgconfig(gstreamer-app-0.10)'


mkdir /tmp/qt
cd /tmp/qt
wget http://download.qt-project.org/official_releases/qt/4.8/4.8.5/qt-everywhere-opensource-src-4.8.5.tar.gz

# for QT 5.2: wget http://www.mirrorservice.org/sites/download.qt-project.org/official_releases/qt/5.2/5.2.0/single/qt-everywhere-opensource-src-5.2.0.tar.gz

tar -xvf qt-everywhere-opensource-src-4.8.5.tar.gz
cd qt-everywhere-opensource-src-4.8.5
#For Qt 4.8.5:  ./configure
#For Qt5.x:  ./configure -qt-xcb
make
make install

#If your shell is bash, ksh, zsh or sh modify ~/.profile file adding:
PATH=/usr/local/Trolltech/Qt-4.8.5/bin:$PATH
export PATH

LD_LIBRARY_PATH=/usr/local/Trolltech/Qt-4.8.5/bin:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH


#in case your shell is csh or tcsh modify ~/.login adding:
setenv PATH /usr/local/Trolltech/Qt-4.8.5/bin:$PATH


4. Install the new virtual machine with CentOS 6.4, select "Minimal Desktop" / RedHat in VirtualBox settings, 4GB RAM
  -- VirtualBox->Devices -> Shared Clipboard -> Bidirectional
  -- VirtualBox->Devices ->Drag-n-Drop-> Bidirectional
  -- VirtualBox->Devices->Install Guest Additions
  -- Network->eth0->connect automatically
  -- System->Preferences->Screensaver - unselect "Auto"


5. Create a new user and add him to sudoers (visudoers as root). Also add
Defaults: root !requirestty
Defaults:your-new-user !requirestty


7. Install QtCreator if required.
cd ~/Qt

# QtCreator 2.8 fails with Segmentation fault  (core dumped) error
# wget http://download.qt-project.org/official_releases/qtcreator/2.8/2.8.0/qt-creator-2.8.0-src.tar.gz
# gzip -d qt-creator-2.8.0-src.tar.gz
# tar -xvf qt-creator-2.8.0-src.tar
# cd  qt-creator-2.8.0-src

# using 2.7.0 instead of failing 2.8.0

wget http://origin.releases.qt-project.org/qtcreator/2.7.0/qt-creator-2.7.0-src.tar.gz
gzip -d  qt-creator-2.7.0-src.tar.gz
tar -xvf qt-creator-2.7.0-src.tar
cd qt-creator-2.7.0-src


sudo /usr/local/Qt-5.1.0/bin/qmake qtcreator.pro

# if an error occures:
# error: dereferencing pointer ‘’ does break strict-aliasing rules
# Then edit corresponding Makefile removing "strict" flag (the build fails otherwise)

# Open in an editor and remove "-Werror" in CXXFLAGS variable
# vi /home/bis/Qt/qt-creator-2.8.0-src/src/shared/qbs/src/lib/Makefile


sudo gmake
sudo gmake install

#check install:
which qtcreator

#should return
/bin/qtcreator