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

Saturday, February 23, 2013

Signing code with a digital certificate on Windows 7

First, download and install Windows 7 SDK if you did not get it yet.

Create an 'info' file "cert.info" to be used by the Microsoft' certificate request utility.
It is a simple text file with content like


[NewRequest]
Subject = "CN=pixamba.com"
Exportable = FALSE
KeyLength = 4096


Some more optional fields are shown here, but you probably do not need them.
Next, open cmd.exe and run there Microsoft' request generation tool:

certreq -new cert.inf cert.req

Upload content of "cert.req" file to your CA server and get a valid certificate for your certificate'  request. How you do it depends on what third party CA you are using.
Providing your CA with a valid certificate request file you should get back from them a valid code signing certificate, either as a file or as text which you copy & save into a e.g. "cert.cer" file.

Once you have received or created such a "cert.cer" file, you run the following command on your Windows machine, forcing it to accept the new certificate:

certreq -accept cert.cer

 Next, run the following command:

"C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\signtool.exe" sign  /v /tr "http://www.startssl.com/timestamp"  mysoftware.exe

- where "mysoftware.exe" is the binary you are willing to sign

Note, that you might have some other (probably old and expired) certificates installed on your machine. In this case you will get the following error message:

SignTool Error: Multiple certificates were found that meet all the given
        criteria. Use the /a option to allow SignTool to choose the best
        certificate automatically or use the /sha1 option with the hash of the
        desired certificate.


If the last certificate you just installed is the only valid certificate you can use simply add "/a" option and signtool will automatically selected. If you have multiple valid certificates installed, tell signtool which one you are willing to use with "/sha1" option and the certificate's hash (printed to the standard output by signtool).

So your final command will probably look like this:
"C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\signtool.exe" sign  /a /v /tr "http://www.startssl.com/timestamp"  mysoftware.exe

This should do the signing, giving you the valid output

Number of files successfully Signed: 1
Number of warnings: 0
Number of errors: 0


I am still looking for the information how it can be done on Windows 8 since Windows 7 SDK installation there fails with errors in the middle and there is no signtool utility in any other location on my Windows 8 machine.

Friday, February 08, 2013

Netbeans freezes up on SVN commit: SOLVED

My Netbenas froze up each time I tried to do a SVN commit.
I found the solution here: https://netbeans.org/bugzilla/show_bug.cgi?id=170770

The problem was simple: NetBeans tried to open the commit dialog in some screen location which it can not access (probably because I am switching between different sets of home and office monitors).

So go to the NB-SVN config file and remove the line defining the commit dialog location. In my case the file is located here:

C:\Users\david\AppData\Roaming\NetBeans\7.2.1\config\Preferences\org\netbeans\modules\

Delete the following line:
svn.commit.dialog=2555.0#179.0#607.0#515.0

- and everything is back to work.

Friday, January 11, 2013

Mail delivery failed while sending to hotmail.com addresses

My server was getting "Mail delivery failed" error while sending emails to Hotmail addresses

SMTP error from remote mail server after MAIL FROM: SIZE=3216:
    host mx1.hotmail.com [65.54.188.72]: 550 SC-001 (BAY0-MC1-F41) Unfortunately, messages from 72.55.188.12 weren't sent. Please contact your Internet service provider since part of their network is on our block list. You can also refer your provider to http://mail.live.com/mail/troubleshooting.aspx#errors.


It's hard to understand what to do next since there is no visible service for Hotmail. After some digging I found  this online form on Microsoft Support site:
https://support.msn.com/eform.aspx?productKey=edfsesc&ct=eformts

Filled it up. Do not know if the issue will be solved, but at least they ask all the right questions there :)

Friday, December 28, 2012

Linux: Killing multiple similar processes all together

kill -9 `ps -ef | grep /libexec/abrt | grep -v grep | awk '{print $2}'`

kill all processes that have "/libexec/abrt" in their run path. Do not kill grep command since it will be alos included into the output.

Saturday, December 15, 2012

Linux: Remove all JPG files older than 5 days

 find . -name *.jpg -mtime +5 -print -exec rm {} \;

# starting from the current directory
# also print the file path

# note spaces around rm and {}

Saturday, December 08, 2012

How To Install ffmpeg on CentOs 6.x (6.3)

I installed ffmpeg on a dedicated CenOs 6.3 server. The installation mostly follows the instrcutions given by the eFFMPEG group here, but there are few important twists if you want to get it done.

1. Login as root

2.Pre-set:
# remove older installations
yum erase ffmpeg x264 x264-devel
 
#verify you get all teh tools:
yum install gcc git make nasm pkgconfig wget
 
#create a working folder
mkdir ~/ffmpeg-source
 
3. Installations
 
#install yam 
cd ~/ffmpeg-source
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
make
make install
 
#install x264
cd ~/ffmpeg-source
git clone git://git.videolan.org/x264
cd x264
./configure --enable-static
make
make install
 
#install mp3 encoder
cd ~/ffmpeg-source
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --disable-shared --enable-nasm
make
make install 

#install libogg
cd ~/ffmpeg-source
wget http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
tar xzvf libogg-1.3.0.tar.gz
cd libogg-1.3.0
./configure --disable-shared
make
make install
 
#install libvorbis
cd ~/ffmpeg-source
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
tar xzvf libvorbis-1.3.3.tar.gz
cd libvorbis-1.3.3
./configure --disable-shared
make
make install 

#install libvpx
cd ~/ffmpeg-source
git clone http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure
make
make install
 
#install zlib
cd ~/ffmpeg-source
wget http://zlib.net/zlib-1.2.7.tar.gz
tar xzvf zlib-1.2.7.tar.gz
cd zlib-1.2.7
./configure
make
make install 

#FFMPEG did not want to work well in /tmp
mkdir ~/tmp
export TMPDIR=~/tmp

#you might also need to add to PATH /usr/lib
export PATH=$PATH:/usr/lib

#and probably add (I did it, but not sure it is a must)
export LD_LIBRARY_PATH=/usr/local/lib

#now install ffmeg from GIT repository
cd ~/ffmpeg-source
git clone git://source.ffmpeg.org/ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264
make
make install
 
#this should work now! type 'ffmpeg' to try
ffmpeg
ffmpeg version N-47639-g0110108 Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec  8 2012 22:03:48 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
  configuration: --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264
  libavutil      52. 12.100 / 52. 12.100
  libavcodec     54. 79.100 / 54. 79.100
  libavformat    54. 48.100 / 54. 48.100
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 26.100 /  3. 26.100
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'