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

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 :)