Sunday, July 7, 2013

Build libssh2 on Visual Studio 2010


In this post I'd like to show you few easy steps how to build libssh2 library with Microsoft Visual Studio 2010.

Recently I started a project which require SSH connection to a server. I've tried few libraries which provide SSH support and libssh2 seems to feet my need the best. It's portable, easy to work with (even the documentation is not great) and has a SSH client support.

Unfortunately the libssh2 comes only as a source code, but fortunately it's very easy to build. The setup I'm using is Microsoft Visual Studio 2010 on Windows 7 64bit.

Even I'm on 64 bit machine I'll build 32 bit version of libssh2. It's easier that way.

Download the sources

First we have to download the sources. The current version is 1.4.3 and can be downloaded from libssh2 website here.

Next in Visual Studio, File->Open->Project/Solution and navigate to libssh-1.4.3\win32. Open libssh2.dsw. The Visual Studio will ask to convert it to 2010 workspace file format. Say YES.

After the it is converted there should be 2 projects in the workspace:

  • libssh2 - the library

  • tests - asimple test application which uses the libssh2 library file created by libssh2 project.

Additional libraries needed

  • openssl can be downloaded from here

  • zlib an be downloaded from here

Both have to be 32 bit as we are going to build 32 bit version of the libssh2.


First thing first - build the library

  1. On the libssh2 project properties C/C++->General->Additional Include Directories add '<path to openssl>\include'.

  2. Go to libssh2_priv.h(43) and comment out the line [sourcecode language="plain"]#define LIBSSH2_LIBRARY[/sourcecode]

  3. libssh2 project properties C/C++->Preprocessor->Preprocessor Definitions and add 'LIBSSH2_LIBRARY'.

 Build the 'test' project

  1. test project properties Linker->General->Output File replace with '%(OutputFile)'

  2. test project properties Linker->General->Additional Library Directories add:

    • '<path to openssl>\lib'

    • '<path to zlib>\static32'. Make sure you rename 'zlibstat.lib' to 'zlib.lib' within this folder as we reference to 'zlib'lib.

    • <path to libssh2.lib>. In my case it is '.\Debug_lib'.

  3. test project properties Linker->Input->Additional Dependencies add zlib.lib and libeay32.lib.

  4. test project properties Debugging->Command and change to '$(OutputPath)\$(TargetFileName)'

  5. test project properties Debugging->Working Directory and change to '$(OutputPath)'

  6. Now if you build you'll probably get:

[sourcecode language="plain"]
simple.obj : error LNK2019: unresolved external symbol __imp__libssh2_exit referenced in function _main
simple.obj : error LNK2019: unresolved external symbol __imp__libssh2_session_free referenced in function _main
simple.obj : error LNK2019: unresolved external symbol __imp__libssh2_session_init_ex referenced in function _main
simple.obj : error LNK2019: unresolved external symbol __imp__libssh2_init referenced in function _main
simple.obj : error LNK2019: unresolved external symbol __imp__libssh2_base64_decode referenced in function _test_libssh2_base64_decode

Go to 'test' project properties C/C++->Preprocessor->Preprocessor Definitions and remove 'LIBSSH2_WIN32'

That's it. Build and Enjoy.

Subscribe for our NewsLetter!

Thursday, July 4, 2013

When will be the next financial crisis?

© Iacobut | Dreamstime Stock Photos & Stock Free Images

Everyone would like to know the answer to this question, but can the next financial crisis be predicted? Wouldn't it be nice if you know in advance and prepare? Even better - you can take advantage of it. ...but what will happen if everybody knows and try to take advantage of it?

It looks like that Didier Sornette has developed a way How we can predict the next financial crisis.

You can watch the video on TED website.

Wednesday, July 3, 2013

Make use of your old Assus EEE PC h1101ha laptop

asus-eee-pc-1101HA-seashellLong time I'm thinking what I can do with an old h1101ha laptop. I didn't want to throw it in the bin, despite the fact it has no working battery anymore.
There few things coming to my mind I can use it for:

- make home automation system

- video player

- network storage

Home automation system is a cool thing and there are many open source software products available. The drawback is that some investments of time and money are needed for all the sensors, actuators, switches and connections. That's the main reason I left this project for later.

The other two – network storage and video player look very straight forward. Just have to install any Linux and that's it. …or is it?

After some research I decided I'll go for Ubuntu. The latest version 13 seems OK. Ubuntu has pretty good support and nice GUI. The only thing I'll have to do after installing it is to set-up the samba server and the XBMC media center.

After installing Ubuntu 13 on the Assus EEE PC it turned out it's not usable. It runs so slowly, that I hardly move the mouse pointer. The fancy desktop manager in the latest Ubuntu is so heavy, that it consumes all the resources of the laptop. It has to be replaced.

The LXDE seems to be the right choice. It runs smoothly on this machine, but the video playback is not the best I've seen. Especially youtube videos.

The next step was to get rid of Ubuntu and try something else – Debian with LXDE desktop. I downloaded the latest Debian Wheezy with LXDE desktop image. It worked much faster, and the playback was good. The problem was that the external monitor didn't run on properly. The xorg modesetting driver made me troubles and the GMA500 (pulsbo) video driver as well.

Again I decided to try one more time. This time with lubuntu. It is a Ubuntu with LXDE desktop. It's lightweight and is based on the latest Ubuntu 13.04 and has the latest xorg.

So far it looks that's the right version.