How to install and configure git with ssh key

  • Download git client depends on your OS platform
  • Open your .ppk key in PuTTY Key generator and export key to OpenSSH key:
  • Content of this OpenSSH key store to file ~/.ssh/id_dsa (copy exported key to ~/.ssh folder and rename it to id_dsa)
  • Now change security permissions on this file to 400 (chmod 400 ~/.ssh/id_dsa)
  • Now cal ssh-add to load id_dsa key

And it’s done. Now you can use your git. For example clone some repository:

git clone ssh://git@server/~/repository/example.git

Automatic ssh-key loading during startup:

TODO

Linux tips

Here is few tricks for Linuch which we needed during our exploration of this system 😉

How to change executable flag for scripts recursively

find -iname '*.sh' | xargs chmod 777

How to configure shared library path

Add file atomix.conf to directory /etc/ld.so.conf.d. To this file enter following:

# atomix libraries
/home/USER_NAME/dev/SharedLibraries/libs

and then run

sudo ldconfig

External link: http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html

VIM cheat sheet

External link: http://www.tuxfiles.org/linuxhelp/vimcheat.html

How to resize partition

Use gparted

sudo apt-get install gparted

Measure disk write speed

time sh -c "dd if=/dev/zero of=ddfile bs=8k count=100000 && sync"

List of usefull links for Visual Studio

How to customize autoexp.dat in Visual Studio 2005

http://mariusbancila.ro/blog/?p=26
http://www.virtualdub.org/blog/pivot/entry.php?id=120

Example visualizator for XString

String::CStringSmart<String::malloc_string_trait<String::string_trait<char> > >{
  preview([$c.m_pszData,s])
  stringview([$c.m_pszData,sb])
}

String::CStringSmart<String::malloc_string_trait<String::string_trait<wchar_t> > >{
  preview([$c.m_pszData,su])
  stringview([$c.m_pszData,sub])
}

How to configure STEP-INTO for Visual Studio 2005

External links:
Google group
www.cprogramming.com

http://blogs.msdn.com/b/andypennell/archive/2004/02/06/69004.aspx

Example how to setup ingoring step-into for MFC CString for VS2005

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\NativeDE\StepOver]
"\"20\""="\\scope:CString.*\\:\\:.*=NoStepInto"
"\"21\""="\\scope:CSmartObjPtr.*\\:\\:.*=NoStepInto"

Example how to setup ingoring step-into for MFC CString for VS2010 on 64bit system

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0_Config\NativeDE\StepOver]
"22"=".*CStringSmart.*=NoStepInto"

Mac OS problem with samba mount

Sometime after some time or when MacOS system is waked-up samba mounts stop working.

Instead of  mounting a drive reporting following error:

mount_smbfs: could not find mount point /mnt/disk_d: Socket is not connected</div>
mount_smbfs: could not find mount point /mnt/disk_e: Socket is not connected</div>
mount_smbfs: mount error: /mnt/disk_p: Socket is not connected</div>

After a little search I found following tip. It could help:

1. Click Start, and then click Run. 
2. Type regedit, and then click OK. 
3. Navigate to the following key: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanServer\Parameters 
4. In the right pane, double-click the IRPStackSize value.

NOTE: If the IRPStackSize value does not already exist, use the following procedure to create it:a. In the Parameters folder of the registry, right-click the right pane. 
b. Point to New, and then click DWord Value. 
c. Type IRPStackSize.

IMPORTANT: Type "IRPStackSize" exactly as it is displayed because the value name is case-sensitive. 

5. Change the Base to decimal. 
6. In the Value Data box, type a value that is larger than the value that is listed. 

If you created the IRPStackSize value using the procedure described in step 4, the default value is 15. It is recommended that you increase the value by 3. Therefore, if the previous value was 11, type 14, and then click OK. 
7. Close the Registry Editor. 
8. Restart the computer.

Simple iconv (libiconv) example

Here is a simple example how to use the iconv library.

#include <iostream>
#include <fstream>
#include <iconv.h>

int main(int argc, char *argv[])
{
	char src[] = "abcčde";
	char dst[100];
	size_t srclen = 6;
	size_t dstlen = 12;

	fprintf(stderr,"in: %s\n",src);

	char * pIn = src;
	char * pOut = ( char*)dst;

	iconv_t conv = iconv_open("UTF-8","CP1250");
	iconv(conv, &pIn, &srclen, &pOut, &dstlen);
	iconv_close(conv);

	fprintf(stderr,"out: %s\n",dst);
}

During my attempts with libiconv library I encountered two different problems:

Converting function returns 0, but pOut is empty

This is because iconv function modify pOut ptr during string processing. When you need to access output buffer after iconv() function finish its work, you have to access it via different pointer than one passed to this function. In my code I’m using *dst and pOut ptrs;

Conversion between different character sets returns strange results

Check if have correct order of parameters in your iconv_open() and iconv() function. Function iconv_open() has as its first parameter OUTPUT encoding, and as second parameter INPUT encoding. While iconv() function has as first parameters INPUT variables, and as second parameters OUTPUT variables. This inconsistency is really confusing.

Notes

Official libiconv site: http://www.gnu.org/software/libiconv/

Official libiconv documentation: http://www.gnu.org/software/libiconv/documentation/libiconv-1.13/

How to compile open-source libraries under Windows using MinGW

Lots of open source libraries (like libiconv, libintl, …) doesn’t have MSVC project files or makefiles. Only supported way how to compile given library under Window is using MinGW and MSYS compiler tools.

Here is step-by-step guide how to download, install and compile libraries using MinGW.

Step one download MinGW

From MinGW home web site http://www.mingw.org/ download “Automated MinGW Installer”. Current version could be downloaded here: http://sourceforge.net/projects/mingw/files_beta/Automated MinGW Installer

Step two installing

Run downloaded executable. As install directory leave C:\MinGW. It’s recommended not to change this path.  On component screen select C compiler, C++compiler, MSYS Basic System and MinGW Developer Toolkit.

After that select next,next,next, finish ;-). After that installer downloads all necessary files. This could take a few minutes.

When installation is done, as next step is necessary to setup PATH variable to c:\MinGW. Installer doesn’t modify it automatically. (more info about modifying PATH variable) .

Installing additional gcc compiler and make support

These two packages isn’t listed in available components. If you wish to install it, use mingw-get-inst. In c:\MinGW\bin directory run following commands:

mingw-get install gcc g++ mingw32-make msys-base

Step three compiling

Compiling from windows shell

Launch cmd tool, go to directory with source code and use g++.

g++ test.cpp

Compiling from MinGW console

Launching MinGW console

Laung MinGW from startmenu or msys.bat from %INSTALL_PATH%\MinGW\msys\1.0\msys.bat.

How to compile libiconv library

As first, download latest libiconv source files from http://www.gnu.org/software/libiconv. And extract whole package somewhere on your disk.

Launch MinGW console and go to the extracted directory. When you extracted directory to the path:

p:\DependentLibrariesWhole\libiconv-1.13.1

Type following command to MinGW console:

cd /p/DependentLibrariesWhole/libiconv-1.13.1

after that, run configure with required library params (in our case we want static and dynamic version of library):

configure --enable-static --enable-shared

and than run make

make

Compiled libraries are located in directory “libiconv-1.13.1\lib\.libs”. There is  additional information about building libiconv library on stackoverflow.

Additional How to guides

This list is compilation of answer to questions and informations how to solve some problems which I had during my installations.

How to get list of available parameters for configure script?

Use “configure –help” command.

How to configure Linux for Qt programming.

How to configure script for automatic run after login

Create .bash_profile file in your home directory.

nano ~/.bash_profile

And enter following content to the new created file:

 # ~/.bash_profile
# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

How to configure new search path

If you want to have bin folder in your home directory, enter following code snippet to your .bash_profile file:

PATH=$PATH;/Users/thomas/bin

Conclusion & Note

It’s possible that all of these task can be done in simpler way, or can’t be done at all. All comments and tips are based on my current experience with my first Linux configuration in my life 😉

How to configure MacOs for Qt programming.

How to configure script for automatic run after login

Create startup-script(or any other)file in your home directory. Then enter following command

nano startup-script
chmod 777 ./startup-script
sudo defaults write com.apple.loginwindow LoginHook /Users/thomas/.startup-script

Another solution is to create .bash_profile file, which is launched automatically by system.

or create

How to configure new search path

If you want to have bin folder in your home directory, enter following code snippet to your .profile file located in your home directory:

export PATH=$PATH:/Users/user_name/bin

Open file using:

nano ./.profile

Note:Path is separated by char “:”.

How to instal apt-get alternative for MacOS

Mac OS have apt-get alternative called “port“.

Additional notes

Realtek RTL81xx macOs version:

How to mount Windows drive from MacOs

As first, create some directory where you want to mount your shared drive

mkdir mnt
cd mnt
mkdir computer_d
mount -t smbfs //user_name:[email protected]/d computer_d

Conclusion & Note

It’s possible that all of these task can be done in simpler way, or can’t be done at all. All comments and tips are based on my current experience with my first MacOS configuration in my life 😉

Qt correct setup for QMAKESPEC, QTDIR and PATH

When you want to use different configurations for different platforms in your .pro file, it’s necessary to correctly setup three variables: QMAKESPEC, QTDIR and PATH.

Here is how to configure for different platforms:

Microsoft Windows:

In SystemPropertes -> Enviroment variables add/update following values:

QTDIR = P:\QT\4.7.0
PATH = %QTDIR%\bin
QMAKESPEC=%QTDIR%\mkspecs\win32-msvc2005
LANG = en_US

Unix Bourne shell: (not tested)

QMAKESPEC=/usr/local/qt/mkspecs/linux-g++
PATH=$PATH:/local/qmake/bin
export QMAKESPEC PATH</pre>

Unix C shell: (not tested)

setenv QMAKESPEC /usr/local/qt/mkspecs/linux-g++
setenv PATH $PATH:/local/qmake/bin</pre>

Note

You can optionally use LANG variable to setup QtCreator language.

Old qt 3.0 guide: http://doc.trolltech.com/3.0/qmake-guide.html
How to configure enviroment: http://doc.qt.nokia.com/4.0/qmake-environment-reference.html

Qt qmake enhancement – how to generate structure VS project

The problem

One of big disadvantage when creating Visual studio project from .pro files using qmake is missing support for hierachical folders. All files are stored in in four folders (filters) named “Source Files”, “Header Files”, “Generated Files” and “Form Files”. When you have large project, this arrangement is really hard to use.

Simple Solution

qmake has undocumented setting parameter “flat”. Using this switch, you can tell qmake to create filters in Visual studio dependent to directory structures of files. Only drawback of this solution is continuing sorting to “Source files”,”Header files”,…

So result of this solution will look like this:

To achieve this behaviour, only thing what have to be done is add following line to your .pro file:

CONFIG -= flat

Final solution

But what to do when you want to have all files stored together in structure dependent on directory structure? Only solution which I found is update qmake project for myself. This update is simply and here is what is need to be done:

Add new method initHeaderAndSourceFiles to file msvc_vcproj.cpp and .h with following content

void VcprojGenerator::initHeaderAndSourceFiles()
{
	vcProject.SourceFiles.Name = "Source And Header Files";
	vcProject.SourceFiles.Filter = "cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx;h;hpp;hxx;hm;inl;inc;xsd";
	vcProject.SourceFiles.Guid = _GUIDSourceFiles;

	vcProject.SourceFiles.addFiles(project->values("HEADERS"));
	vcProject.SourceFiles.addFiles(project->values("SOURCES"));
	if (usePCH) // Generated PCH cpp file
		vcProject.HeaderFiles.addFile(precompH);

	vcProject.SourceFiles.Project = this;
	vcProject.SourceFiles.Config = &(vcProject.Configuration);
	vcProject.SourceFiles.CustomBuild = none;
}

and update method VcprojGenerator::initProject() in msvc_vcproj.cpp file. Replace following two lines (currently located on line 762)

initSourceFiles();
initHeaderFiles();

with following code:

if ( project->isActiveConfig("grouped") == false ) {
	initSourceFiles();
	initHeaderFiles();
}
else {
	initHeaderAndSourceFiles();
}

Now you can add new flag “grouped” to your .pro file. After that, source and header files will be merged in the visual studio project tree.

CONFIG -= flat
CONFIG += grouped

And here is result screenshot:

First Qt attempts – qmake troubles

External links

qmake documentation: qmake tutorial.html
qmake variables: qmake variable reference

Generate vcproj from .pro file

Command line for generating Visual studio project file from Qt .pro file.

qmake -tp vc test.pro

Missing moc_*.cpp file

When some of moc file isn’t properly generated and getting following error:

c1xx : fatal error C1083: Cannot open source file: '.\debug\moc_xxx.cpp': No such file or directory

try following:
Select corresponding .h file (for moc_xxx.cpp select xxx.h) in a project tree and select Compile from context menu. If the file is marked as “up-to-date“, try to change something in this file and repeat a compilation. If in the output window will be “up-to-date” again, you found a problem.

Use context menu on the corresponding .h file, select properties and edit “Configuration properties |Custom build steps|General|Outputs” to any value (add some char to the end of value), confirm change by Ok button and then return value back to original (remove added char). After that, compilation on correspond file will be successfully performed.

Linux relevant tips

List of known issues and tips

This is list of all known issues and problems which we had to solve during our first Qt installation on Linux, Windows and Mac.

Known errors

Error: undefined interface

What to do when compilation of QT crash with message “Error: undefined interface”.
http://www.qtforum.org/article/31561/error-when-building-libraries.html
http://www.qtcentre.org/threads/26245-Qt-4.6-api/qscriptextensionplugin.h(43)-Error-Undefined-interface

make: g++: Command not found

it’s necessary to instal g++ support (sudo apt-get install g+)

Basic XLib functionality test failed!

it’s necessary to instal xlib(xorg??) support (sudo apt-get install xorg-dev)

*** [sub-corelib-make_default-ordered] Error 2

Probably mishmash on 32bit / 64bit  system and QT versions.

undefined reference to `QEventDispatcherGlib::versionSupported()’

Probably missing libglib2.0-dev on your system. (sudo apt-get install libglib2.0-dev).

Undefined reference to QSslSocket::*

Missing OpenSSL library on your system. (sudo apt-get install libssl-dev)

gtk/gtk.h: No such file or directory

Missing gtk package. (sudo apt-get install libgtk2.0-dev ). After that its necessary to update db (sudo updatedb).

if system can’t find file gtk/gtk.h because gtk is stored in gtk-2.0 directory, add -I (capitalised i) param to configure with gtk path:

./configure -opensource -I /usr/include/gtk-2.0

cups/cups.h: No such file or directory

install libcups2. (sudo apt-get install libcups2-dev)

gst/gst.h: No such file or directory

install gstreamer 0.10. (sudo apt-get install libgstreamer0.10-dev)

Missing Include/glibconfig.h

it’s because this file isn’t in /usr/include/glib-2.0, but in /usr/lib/glib-2.0. So you have to include also this /usr/lib path or copy file to include/glib-2.0

Hints and tips

How to create symbolic link to directory

create symbolic link using ln -nsf /usr/include/gtk-2.0/gtk /usr/include/gtk

Minimal required libraries

List of libraries required by Qt:

  • libfontconfig1-dev
  • libfreetype6-dev
  • libx11-dev
  • libxcursor-dev
  • libxext-dev
  • libxfixes-dev
  • libxft-dev
  • libxi-dev
  • libxrandr-dev
  • libxrender-dev

And other which are required by some modules of Qt:

To install all required on Linux, use following commands

sudo apt-get install libfontconfig1-dev libfreetype6-dev libx11-dev libxcursor-dev libxext-dev libxfixes-dev libxcups/cups.h: No such file or directory ft-dev libxi-dev libxrandr-dev libxrender-dev

sudo apt-get install bison flex libqt4-dev libqt4-opengl-dev libphonon-dev libicu-dev libsqlite3-dev libxext-dev libxrender-dev gperf libfontconfig1-dev libphonon-dev

If error doesn’t disappear after installing correct library

Sometimes it’s necessary to reconfigure Qt using make confclean

How to find where is missing header file located on disk

Use find /path -iname xxx.h command

How to find package which contains missing header file

use apt-file application with following syntax:

apt-file search gdk/gdk.h

Useful links about instalation Qt on linux

List of links about installation:
Building Qt on Linux

Qt configuration for succesfull build

This is currently my latest configure command to compile Qt on my Ubuntu 10.10.

Compilation fixes

This is necessary when search path for following libraries isn’t entered to configure.

sudo ln -nsf /usr/include/gstreamer-0.10/gst /usr/include/gst

Todo

Figure out how works pkg-config (pkg-config –cflags gstreamer-0.10)

Qt installation and configuration

This is our company step-by-step guide to install and configure Qt on our developer machines.

How to install Qt

Link to Qt download site: http://qt.nokia.com/downloads

Windows (VS2005)

Download VS 2008 distribution from download site. When 2008 distribution is downloaded, it’s necessary to reconfigure and rebuild it for VS 2005 using next steps.

Linux

Download linux/x11 distro from Qt page. Download 32/64bit distro package. Setup downloaded files as executables:

chmod +x qt-sdk-linux-x86-opensource-2009.01.bin
chmod +x qt-creator-linux-x86-opensource-1.0.0.bin

Install Qt sdk to default directory and begin with configuration.

MacOS

Download latest Qt SDK distribution and latest XCode developer pack from apple site. Then install both.

How to configure Qt

Qt configuration is done via Configure script/executable on all platforms.

Windows

Run “Start menu->Visual studio->Tools-> Visual studio command prompt”
Then go to “c:\Qt\Qt_Version\Qt” and run “configure” with additional params.

Our current configuration:

configure -debug-and-release -opensource -shared -platform win32-msvc2005 -incredibuild-xge -openssl

Clean configurations

run nmake confclean and nmake distclean to remove all previous version of QT compilations.

SSL support

For SSL Support add -openssl switch to configure.

Note!

: configure param HAVE TO be executed from Visual studio command prompt!

Linux

Enter Qt directory and enter following configure param:

./configure -opensource -I /usr/include/gtk-2.0 -L /usr/lib/gt-2.0 -I  /usr/include/gstreamer-0.10 -L /usr/lib/gstreamer-0.10 -I /usr/include/glib-2.0 -L /usr/lib/glib-2.0 -I /usr/include/libxml2 -fast

Clean configurations

run make confclean and then configure.

MacOS

How to compile Qt

Windows

Compile Qt using command prompt:

  • Run Visual studio command prompt.
  • And run nmake to build a whole library

Second option is open projects.sln located in p:/Qt/4.7.1/ using Visual Studio IDE  and compile it.

Linux

  • As first thing, use configure to setup Qt settings.
  • As next, run make to build a whole library
  • After a while when everything is compiled, use make install. This will install library to /usr/local/Trolltech/Qt-4.7.0

MacOS

Currently not tested, using default compilation.

How to compile application

When we have prepared Qt library, it’s time to compile our application.

MacOS

When using  qmake without additional params, qmake generate xcode project from .pro instad makefile for g++. To generate makefile, use following params:

qmake -spec macx-g++
make

Deploying application

Windows

Not testes.

External link: http://doc.trolltech.com/4.5/deployment-windows.html

Linux

Not testes.

MacOS

Not testes.