Saturday, February 15, 2014

Set up another timezone in Linux

#make sure NTPDd runs on reboot so the clock is synchronized
chkconfig ntpd on


#modify clock file:
vi /etc/sysconfig/clock


#and put your zone there, e.g.:
#ZONE="America/New_York"
ZONE="Asia/Jerusalem"
#UTC=True
UTC=False



#backup previous 'localtime ' file

mv /etc/localtime /etc/localtime.original

# and create a link to the zone file you've selected:
ln -s /usr/share/zoneinfo/Asia/Jerusalem /etc/localtime

# now verify that 'date' shows teh desired timezone [Israeli time (IST)]
date

CMake Error when compiling on AWS AMI CentOs / Fedora / RedHat family

If you are getting this error

CMake Error at /usr/local/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.
  Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
  system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES
  OPENSSL_INCLUDE_DIR) (Required is at least version "0.9.8")

it is because RedHat decided to pre-install [a stripped down version of] OpenSSL and you do not have the developers package there.

Try this:

rpm -qa | grep openssl

If you got only

openssl-1.0.1e-16.el6_5.4.x86_64

Install the development package which got the headers and the extras

sudo yum -y install openssl-devel

and then run cmake command again

Wednesday, February 12, 2014

SSH/SCP to a remote machine / AWS from a terminal with a security key

Both 'ssh' and 'scp' Linux/Unix commands got '-i' option which accepts a path to the key file, so the commands look this way:

ssh -i /path/to/my/key/file.pem user@111.222.333.444

scp -i /path/to/my/key/file.pem ./src_file.gz user@111.222.333.444:/tmp/destintation_file.gz

Wednesday, December 18, 2013

VirtualBox - building Guest Additions on CentOs 6.5 fails: openGL & X11 are not installed

If your VirtualBox became small, ugly and lost Copy&Paste capabilities try running VB Guest Additions install. However if are getting the below error, while running VirtualBox Guest Addition Installation
Building the OpenGL support module     [FAILED]
here is the way to deal with it.

Here is a patch for OpenGL failure described here, slightly modified to support various kernel' versions:
cd /usr/src/kernels/`uname -r`/include/drm/  
ln -s /usr/include/drm/drm.h drm.h  
ln -s /usr/include/drm/drm_sarea.h drm_sarea.h  
ln -s /usr/include/drm/drm_mode.h drm_mode.h  
ln -s /usr/include/drm/drm_fourcc.h drm_fourcc.h

Well, this is not enough if you already tried installing Guest Additions in the past and it failed!

To avoid the  below error

Installing graphics libraries and desktop services components ...fail! (See the log file /var/log/vboxadd-install-x11.log for more information.) Press Return to close this window... install_x11_startup_app: no script given

you also have manually remove two folders as described here and here:

rm -rf /usr/lib64/VBoxGuestAdditions
rm -rf /usr/share/VBoxGuestAdditions
rm -rf /opt/VBoxGuestAdditions


Now run the installer:
cd /media/VBOXADDITIONS_4.3.4_91027
./VBoxLinuxAdditions.run

You might get a warning from the installer, but that's fine - type in "yes" and wait until everything compiles and installs.

Monday, November 18, 2013

Installing OpenCV 2.4.7 on CentOs 6.4

# login as root & make sure cmake 2.8+ is installed

cd /tmp
mkdir opencv
cd opencv/
wget http://garr.dl.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.7/opencv-2.4.7.tar.gz
tar -xvf opencv-2.4.7.tar.gz
cd opencv-2.4.7
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
make install

Thursday, August 29, 2013

Build Apache log4cxx on Microsoft Windows

  1. Download the latest log4cxx package from here
  2. Download apr and apr-util ZIP packages from here
  3. Extract log4cxx, apr und apr-util to the same directory so that directory will look like    apache-log4cxx-0.10.0aprapr-util
  4. Rename apr-xxx to apr as shown above, rename apr-util-xxx to apr-util as shown above
  5. Open cmd.exe and type in:
  6. cd apache-log4cxx-0.10.0
  7. .\configure.bat
  8. Change to apr-util/include direcotry and open apu-hw in a texteditor of your choice
  9. Find the entry #define APU_HAVE_APR_ICONV, set it to 0 and save the file 
  10. Open apr_ldap.hw from the same directory and find the entry #define APR_HAS_LDAP, set it to 0 and save the file, too  
  11. Change to log4cxx/projects directory and open log4cxx.dsw with MS VC++ 2012 ( I got Express version installed)
  12.  Answer Yes/OK to every question and build the solution. You are supposed to get about 111 Errors: "error C2252: an explicit instantiation of a template can only occur at namespace scope"
    1. Move all those LOG4CXX_LIST_DEF macros to before the class definition. in telnetappender.h you will also need to move the typedef that precedes this macro.
    2. If the compiler complains about KeySet not being member of LoggingEvent, just remove the scope (since we moved the type to outside the class in the previous step, these types no longer are inside the class) ex: change: LoggingEvent::KeySet set; to: KeySet set;
    3. in simpledtaeformat.h put the DEFINE after 'helpers' namespace definition, i.e.  namespace log4cxx
      {
              namespace helpers
              {
                namespace SimpleDateFormatImpl {
                  class PatternToken;
              }

              LOG4CXX_LIST_DEF(PatternTokenList, log4cxx::helpers::SimpleDateFormatImpl::PatternToken*);
  13. References:
    1. http://www.codeproject.com/Tips/492585/How-to-build-log4cxx-with-Visual-Studio-2010
    2.  
    3. http://blog.wupingxin.net/2011/09/11/build-log4cxx-with-visual-studio-2010/

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