Wednesday, June 29, 2016

Ubuntu software update can not run due to insufficient disk space

This one-liner does the clean up:
dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p' | xargs sudo apt-get -y purge

(source)

Tuesday, May 24, 2016

Make Mozilla Thunderbird to properly work with your Google Calendar

Thunderbird uses it's own default "Home" calendar so you need to re-configure it if you want to use your Google Calndar via Lightning plugin.
  1. Manually copy upcoming event from Home calendar to Google calendar (e.g. by creating new events at http://calendar.google.com).
  2. Remove "Home" calendar: "Events and Tasks" -> Unsubscribe selected Calendar -> Home
  3. Download & install "Provider for Google Calendar": https://addons.mozilla.org/en-US/thunderbird/addon/provider-for-google-calendar/, restart Thunderbird
  4. Add your Google calendar: File->New->Calendar->Network Calendar->Google CalendarEnter your email address and then,in the Google authorization window, provide your Google account credentials .
  5.  Last but not least: allow the calendar to accept incoming events and send notifications.Options->Advanced->Config EditorType in the search bar: calendar.google.enableEmailInvitations and click on item to make it 'true'

Sunday, November 29, 2015

Setup a swap file for Linux / Ubuntu

Set up a swap file of 2GB in the "/" folder and attach swap to it

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Test:

sudo swapon -s
free -m

Make your changes permanent:

sudo vi /etc/fstab

Add the following line:

/swapfile   none    swap    sw    0   0

save & close the file.

Twek swapinness (0-100). If near to 0 the kernel  will use swap only it is absolutely necessary.  Values near to 100 mean use more swap and use less RAM.
To see swappiness:
 
cat /proc/sys/vm/swappiness
 
and to change it
 
sudo vi /etc/sysctl.conf 
 
and add at the end of the file

vm.swappiness=10
 
(source) 

Saturday, November 21, 2015

s3cmd for Ubuntu

Installing s3cmd on Ubuntu is really easy:

sudo apt-get install s3cmd
 
and then

s3cmd --configure


Note the utility saves .s3cfg file in your home directory (if not requested differently), so for another user you will have to re-configure it or copy your ~/.s3cfg file and modify it, or run

s3cmd -c ...

Trying it out:

echo "test" ~/test.txt
s3cmd --mime-type='plain/text' put ~/test.txt s3://mybucket 

Explicitly specifying the MIME type avoids s3cmd to do any guesswork trying to determine the file' MIME type.



Friday, November 13, 2015

Qt: "undefined reference to vtable" while inheriting from QObject

Linker' error "undefined reference to vtable" in QT 5.5.1 (Linux-64 g++ 4.8) can be fixed by doing both these things:
a) rm - rf /*
(e.g. /build-myapp-Desktop_Qt_5_5_1_GCC_64bit)
b) moving the QObject definition in .h file next to public / private keyword, i.e. instead of

class Abc : public AnotherClass, QObject

make it

class Abc : public QObject, AnotherClass

Once done, rebuild the project.

Tuesday, November 03, 2015

Installing log4cxx and rdkafka libraries on Ubuntu 14.04 (@VirtualBox)

Installing log4cxx

sudo apt-get install autoconf automake
sudo apt-get install libxml2 libxml2-dev
sudo apt-get install libboost-dev
sudo apt-get install libcppunit-dev

sudo apt-get install libapr1 libaprutil1
sudo apt-get install liblog4cxx10 liblog4cxx10-dev 

If you want to check where it was installed:

sudo dpkg -L liblog4cxx10

For QtCreator add to your ".pro" project file the following:

LIBS += -lapr-1 -laprutil-1 -llog4cxx

(reference)

Installing csi-kafka from the source:

# pre-requisits
 
sudo apt-get install -y automake autogen shtool libtool git wget cmake unzip build-essential g++ python-dev autotools-dev libicu-dev zlib1g-dev openssl libssl-dev libcurl4-openssl-dev libbz2-dev libcurl3 libpq-dev
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz/download -Oboost_1_59_0.tar.gz 
# installing boost librbaries
 
tar xvf boost_1_59_0.tar.gz
cd boost_1_59_0
sudo ./bootstrap.sh --prefix=/usr/local
./b2 -j 8 threading=multi
sudo ./b2 install --prefix=/usr/local
cd..
 
# add symbolic links to some boost libs so we'll find our libraries in the run time
  
sudo ln -sf /usr/local/lib/libboost_system.so.1.59.0 /lib/x86_64-linux-gnu/libboost_system.so.1.59.0
sudo ln -sf /usr/local/lib/libboost_thread.so.1.59.0 /lib/x86_64-linux-gnu/libboost_thread.so.1.59.0
sudo ln -sf /usr/local/lib/libboost_log.so.1.59.0 /lib/x86_64-linux-gnu/libboost_log.so.1.59.0
sudo ln -sf /usr/local/lib/libboost_filesystem.so.1.59.0 /lib/x86_64-linux-gnu/libboost_filesystem.so.1.59.0 
 
# installing csi-kafka librbaries
  
git clone https://github.com/bitbouncer/csi-build-scripts.git
git clone https://github.com/bitbouncer/csi-kafka.git  
 
cd csi-kafka
bash -e ./build_linux.sh
cd csi_kafka/
 
# copy lib & includes to a well-known location
  
sudo mkdir /usr/include/csi_kafka
sudo mkdir /usr/include/csi_kafka/internal
sudo cp *.h /usr/include/csi_kafka
sudo cp internal/*.h /usr/include/csi_kafka/internal/
cd ..
sudo cp lib/libcsi-kafka.a /usr/local/lib/
sudo ln -sf /usr/local/lib/libcsi-kafka.a /lib/x86_64-linux-gnu/libcsi-kafka.a

#for QtCreator, add:
 
QMAKE_CXXFLAGS += -std=c++11 -DBOOST_LOG_DYN_LINK

LIBS += -lboost_system -lboost_thread -lboost_log -lcsi-kafka
Running some samples require zookepercli utility

wget https://github.com/outbrain/zookeepercli/releases/download/v1.0.10/zookeepercli_1.0.10_amd64.deb 
sudo dpkg -i zookeepercli_1.0.10_amd64.deb

Installing librdkafka library from the source:

mkdir librdkafka
git clone https://github.com/edenhill/librdkafka.git librdkafka/
cd librdkafka/
./configure
make
sudo make install

On my system the intsall was into
/usr/local/lib/

ubuntuVM:~/librdkafka/examples$ ls -l /usr/local/lib/librdkafka*
-rwxr-xr-x 1 root root 1958676 Nov  5 08:34 /usr/local/lib/librdkafka.a
-rwxr-xr-x 1 root root  875272 Nov  5 08:34 /usr/local/lib/librdkafka++.a
lrwxrwxrwx 1 root root      15 Nov  5 08:34 /usr/local/lib/librdkafka.so -> librdkafka.so.1
lrwxrwxrwx 1 root root      17 Nov  5 08:34 /usr/local/lib/librdkafka++.so -> librdkafka++.so.1
-rwxr-xr-x 1 root root  943720 Nov  5 08:34 /usr/local/lib/librdkafka.so.1
-rwxr-xr-x 1 root root  354163 Nov  5 08:34 /usr/local/lib/librdkafka++.so.1


Create symbolic links so the shared RDKAFKA libraries could be found in run time when the application starts:
  
sudo ln -sf /usr/local/lib/librdkafka++.so.1 /lib/x86_64-linux-gnu/librdkafka++.so.1

sudo ln -sf /usr/local/lib/librdkafka.so.1 /lib/x86_64-linux-gnu/librdkafka.so.1

The correct order of the RDKAFKA libraries if you use C++ is as follow (note that rdkafka++ is prior to rdkafka):

-lz -lpthread -lrt -lrdkafka++ -lrdkafka

So the LIBS for QtCreator now looks this way


LIBS += -lapr-1 -laprutil-1 -llog4cxx \
        -lz -lpthread -lrt -lrdkafka++ -lrdkafka

Sunday, November 01, 2015

Installing Qt5.5.1 on Ubuntu 14.04 at VirtualBox

Step 1: Install pre-requisits

Instal pre-requisists following Building Qt From Git article:

sudo apt-get build-dep qt5-default

sudo apt-get install build-essential perl python git


sudo apt-get install "^libxcb.*" libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev

sudo apt-get install flex bison gperf libicu-dev libxslt-dev ruby

sudo apt-get install libssl-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libfontconfig1-dev

sudo apt-get install libcap-dev libbz2-dev libgcrypt11-dev libpci-dev libnss3-dev build-essential libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libdrm-dev libfontconfig1-dev libxtst-dev libasound2-dev gperf libcups2-dev libpulse-dev libudev-dev libssl-dev flex bison ruby

sudo apt-get install libasound2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

Step 2A: The easy way

Get the latest Qt binaries and run them, e.g.
wget http://qt.mirror.constant.com/archive/qt/5.5/5.5.1/qt-opensource-linux-x64-5.5.1.run
chmod 755 qt-opensource-linux-x64-5.5.1.run
sudo ./qt-opensource-linux-x64-5.5.1.run

Then go to step 4 and skip steps 2B-3B.

Step 2B: Get & Compile Qt from the Sources

The easy way described in Step 2A above is a much better way to go.

Go to the folder where Qt src file resides (e.g. ~/Downloads):

tar -xvf qt-everywhere-opensource-src-5.5.1.tar.gz
sudo mkdir /opt/qt5.5.1
cd qt-everywhere-opensource-src-5.5.1/

 ./configure -prefix /opt/qt5.5.1 -opensource -confirm-license -gstreamer

[it took nearly 6h to complete on my i7+SSD Dell Vostro with 12GB RAM given to Ubuntu VM]

Now we have to let the system know we are willing to use teh new Qt instead of the old default one:
Edit file (reference):

sudo vi /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf

and make it look exactly like this:

/opt/qt5.5.1/bin
/opt/qt5.5.1/lib


(assuming Qt is installed in /opt/qt5.5.1 folder). Check what you got:





qtchooser -print-env

should now print

QT_SELECT="default"
QTTOOLDIR="/opt/qt5.5.1/bin"
QTLIBDIR="/opt/qt5.5.1/lib"

and

qmake -v

should say

QMake version 3.0
Using Qt version 5.5.1 in /opt/qt5.5.1/lib


Step 3B:  Get source & build QtCreator

Now let's build QtCreator from source: first, create a folder for the source code from git, e.g.


mkdir ~/Downloads/qtcreator
cd qtcreator
git clone --recursive git://code.qt.io/qt-creator/qt-creator.git 

Create a new folder for build (MUST be at the same level like qt-creator source code folder):


mkdir qtcreator-build
cd qtcreator-build/
qmake -r ../qt-creator/qtcreator.pro
make
sudo make install

Step 4: Get QtCreator work

On a run attempt QtCreator fails:

qtcreator
libGL error: pci id for fd 22: 80ee:beef, driver (null)
OpenGL Warning: glFlushVertexArrayRangeNV not found in mesa table
OpenGL Warning: glVertexArrayRangeNV not found in mesa table
OpenGL Warning: glCombinerInputNV not found in mesa table
OpenGL Warning: glCombinerOutputNV not found in mesa table
OpenGL Warning: glCombinerParameterfNV not found in mesa table
OpenGL Warning: glCombinerParameterfvNV not found in mesa table
OpenGL Warning: glCombinerParameteriNV not found in mesa table
OpenGL Warning: glCombinerParameterivNV not found in mesa table
OpenGL Warning: glFinalCombinerInputNV not found in mesa table
OpenGL Warning: glGetCombinerInputParameterfvNV not found in mesa table
OpenGL Warning: glGetCombinerInputParameterivNV not found in mesa table
OpenGL Warning: glGetCombinerOutputParameterfvNV not found in mesa table
OpenGL Warning: glGetCombinerOutputParameterivNV not found in mesa table
OpenGL Warning: glGetFinalCombinerInputParameterfvNV not found in mesa table
OpenGL Warning: glGetFinalCombinerInputParameterivNV not found in mesa table
OpenGL Warning: glDeleteFencesNV not found in mesa table
OpenGL Warning: glFinishFenceNV not found in mesa table
OpenGL Warning: glGenFencesNV not found in mesa table
OpenGL Warning: glGetFenceivNV not found in mesa table
OpenGL Warning: glIsFenceNV not found in mesa table
OpenGL Warning: glSetFenceNV not found in mesa table
OpenGL Warning: glTestFenceNV not found in mesa table
libGL error: core dri or dri2 extension not found
libGL error: failed to load driver: vboxvideo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 00000000029efa10
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: XGetVisualInfo returned 0 visuals for 00000000029efa10
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 00000000029efa10, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 00000000029efa10
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 00000000029efa10, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 00000000029efa10
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 00000000029efa10, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 00000000029efa10
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 00000000029efa10, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 00000000029efa10
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 00000000029efa10, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 00000000029efa10
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 00000000029efa10, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 00000000029efa10
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 00000000029efa10, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 00000000029efa10
OpenGL Warning: Retry with 0x8002 returned 0 visuals
OpenGL Warning: glXGetFBConfigAttrib for 00000000029efa10, failed to get XVisualInfo
OpenGL Warning: XGetVisualInfo returned 0 visuals for 00000000029efa10
OpenGL Warning: Retry with 0x8002 returned 0 visuals
Could not initialize GLX
Aborted (core dumped)


The only solution I found was shutting down  my VirtualBox VM, go to Settings->Display and switch OFF 3-D acceleration like suggsted here.

I still got some run-time errors:

libGL error: pci id for fd 22: 80ee:beef, driver (null)
libGL error: core dri or dri2 extension not found
libGL error: failed to load driver: vboxvideo


but now QtCreator window opened.