Sunday, May 6, 2012

Mysql Connector/C++ build and install from source

1. Install Cmake build tool


sudo apt-get install cmake


2. Install libmysqlclient16-dev library



sudo apt-get install libmysqlclient16-dev



3. Install squeeze (stable) Build platform



sudo apt-get install squeeze




4. Go to the Mysql download page and download the source for c++ connector, extract it and go into the folder using terminal.

5. Set the following  environment variables


export CC=gcc
export CFLAGS=-O1-g
export CPPFLAGS=-DNDEBUG
export CXX=g++
export CXXFLAGS=-O1-gexport CC=gcc
export CFLAGS=-O1-g
export CPPFLAGS=-DNDEBUG
export CXX=g++
export CXXFLAGS=-O1-g
export LDFLAGS=-static-libgcc
export PICOPT=-fPIC
export LDFLAGS=-static-libgcc
export PICOPT=-fPIC


6. Edit file in following locations and add missing includes.

   i.  Add #include <cstdio>  to driver/mysql_art_resultset.cpp 
   ii. Add #include <stdio.h>  to driver/mysql_resultbind.cpp 
   iii. Add #include <stdio.h>  to test/unit/classes/resultsetmetadata.cpp

7.  Run


cmake .
make 
make install






Saturday, May 5, 2012

Ubuntu Cmake issue with mysql c++ connector

I have encountered an error while i try to follow the installation instructions on this page for compiling mysql c++ client. One of the errors was the misleading info in download link of the page . It direct you to linux generic code page and if you download the linux generic code you are dhoomed (you will get bunch of libraries and nothing to compile).

So first you have to download the source code for the connector ( not the linux generic code ).

Then i encountered this weird problem when i try to compile things.


-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/cc
-- Check for working CXX compiler: /usr/bin/cc -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- ENV{MYSQL_DIR} = 
CMake Error at FindMySQL.cm:165 (MESSAGE):
  mysql_config wasn't found, -DMYSQL_CONFIG_EXECUTABLE=...
Call Stack (most recent call first):
  CMakeLists.txt:55 (INCLUDE)


CMake Error at FindMySQL.cm:167 (MESSAGE):
  Cannot find MySQL.  Include dir: MYSQL_INCLUDE_DIR-NOTFOUND library dir:
  cxxflags:
Call Stack (most recent call first):
  CMakeLists.txt:55 (INCLUDE)


-- Configuring incomplete, errors occurred!

Here I can see more than one problems, in tutorial you have no instruction to declare a variable named MYSQL_DIR. But here you need a one so type 

Which mysql

and export it as

export MYSQL_DIR=/usr/bin/mysql

Then for the configuration file missing error you have to install libmysqlclient16-dev library to have mysql_configure file in your system. So type,


sudo apt-get install libmysqlclient16-dev

How to handle octave configure error in package instalation

If you try to install a package in Octave programming language using


pkg install package_name.tar.gz


you might encounter this error which stops the installation of package.

example :

configure: WARNING: no mkoctfile found on path
./configure: line 2918: conftest.cc: command not found
configure: error: Could not run 
the configure script returned the following error: checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for mkoctfile... no
error: called from `pkg>configure_make' in file /usr/share/octave/3.2.4/m/pkg/pkg.m near line 1240, column 2
error: called from:
error:   /usr/share/octave/3.2.4/m/pkg/pkg.m at line 714, column 5
error:   /usr/share/octave/3.2.4/m/pkg/pkg.m at line 287, column 7

For me the reason was i have not installed the octave header files when i m installing octave on my linux (ubuntu 11.10). So installing the headers for my octave version fixed the problem.

In linux terminal type,

sudo apt-get install octave3.2-headers libncurses5-dev

And after the installation finished run octave in super user mood to install the packages.

sudo octave





Thursday, May 3, 2012

How to copy a google chrome cache flash video in linux

I wanted to copy a flash video which is playing in my google chrome browser. In windows this can be achieved using simple tool called video cache viewer. But in linux story is much more different as it is difficult.

So with this article i will explain how to achieve this task.

1. open a terminal and type


ps -ef | grep flash

this will show the process id of you flashplayer (make sure to select the flash process which used by chrome browser)


2. then go to "/proc" directory and go into the folder named by the process id that you have obtained in     step 1. And go into the "fd" folder.


ex: lets assume that the process id of the flash used in chrome is 2424
now you should be inside "~/proc/2424/fd" directory

3. then type


ls -al | grep *flash*


this will show all the flash file descriptors  like below

lrwx------ 1 user user 64 2012-05-02 23:15 21 -> /tmp/FlashXXtD6PiG (deleted) lr-x------ 1 user user 64 2012-05-02 23:15 27 -> /tmp/FlashXXrotLjm (deleted) lrwx------ 1 user user 64 2012-05-02 23:15 3 -> socket:[22151] lrwx------ 1 user user 64 2012-05-02 23:15 4 -> socket:[25121]


Ones that has been highlighted in orange  color are the file descriptors of the flash files that have been opened. Walah!!! we r done copy them to where ever folder you want by simple


cp <file_des_no> destination




Tuesday, May 1, 2012

SQL join and optimization experience

I came across my sql join few days ago. The database i created was a temporary one and it is not for a product or something, this just used to store some web  logs that i used for my final year research.

So what i wanna do was join two tables that has about 100 thousand records in both of the tables. But with my simple inner join query it took more than 10 hours but still did not complete.

So i was searching for the ways to increase the performance of the join query and found out that introducing indexes increase the performance in considerable amount of time.

two things i have done was,


  1. Adding primary key constrains 
  2. Adding foreign key constrains 
to my two tables which i have not add previously because this was just temporary tables.

And then the query resulted within 2 minutes for the same number of records.