How to use libssh in VS10
Asked Answered
L

4

10

How can I implement libssh as a library my compiler will recognize? I'm using Visual Studio 2010 C++, and I've included the Boost library with no problems, but the process I did with Boost is strange, I can tell libssh will be different.

I really don't want to do a DLL file, I want one executable, however I know that DLL files can be embedded inside of executables through .rc scripting. (Then extract and load)

I've never had to include a library except for Boost into any of my projects, I feel like I should really know how to do this. Please note this is libssh not libssh2. Thanks.

Lesseps answered 20/11, 2011 at 19:58 Comment(1)
Recommend to read the following anwser #496295Ferrick
S
15

Even if the post is old i have an answer, maybe it can be helpful for someone dropping here.

To implement libssh into Visual Studio 2010.

You will need more than just one library you will need 3 to be sure everything will compile well. First download the last version of libssh After this you will need 2 more dll, to be allow to compile without issue:

  • libeay32.dll
  • zlib1.dll

For the first one it wasn't recognize very well for me, so i just took the full library of openssl openssl-0.9.8k_WIN32.zip

After you have dowloaded those files place them into the rigth place in Visual studio.

go to

  • C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC

To open the visual studio for the language C -> VC Then :

  • Copy the folder with the include in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include paste the folder libssh\include (containing all .h file)
  • Copy the file ssh.lib into C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib
  • Copy ssh.dll C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin

Copy libeay32.dll and zlib1.dll into the bin folder. Or if you downloaded openssl which I recommend then you just do the same proces ass for lib ssh just dont forget to copy also the .exe file into the bin folder with the dll.

It is not finished yet after that you'll have to link the libraries into the compiler of your project.

Project -> projectName properties a windows open with properties then go -> Configuration Properties -> Linker -> input -> Additional Dependencies.

Now add the following libraries into the dependencies

;ssh.lib;ssleay32.lib;libeay32.lib;

And then it was working very well

I hope that it can help someone dropping by here :)

Sulamith answered 2/12, 2012 at 4:5 Comment(3)
Thank you for your post; this is definitely the most comprehensive guide I have seen for libssh.Lesseps
@Raphael Teubner What libeay32.dll and zlib1.dll are used for libssh?Titrant
Yes it seems there is some dependency issue if they are not included. Just compile without it an check the long list of dependency error at compilation time and it show so I guess it needs it.Sulamith
H
2

The standard windows installer does not come with static libs.

IMPORTANT You'll end up with openssl dynamically linked (zlib optionally) anyway. Are you sure you want this?

In case you do, you need

optional: - libz >= 1.2

  1. Download the source zip,
  2. create an out-of-sourcetree build directory,
  3. start cmake-gui, tweak
    • select source and build dirs
    • click configure (e.g. I chose VS2010 Win64 build files)
    • open VStudio, tweak and build as static library (instead of DLL)

Hope this will help you get started.

Hannigan answered 20/11, 2011 at 20:58 Comment(1)
Here is a quick-and-dirty static build I did with VS2010 on XP64; note it disabled LIBZ support (because I'm lazy :)) still it might help you get started (there was an include error in log.c too). Note how this is quick and dirty because (a) I didn't change the directory names, they still are called 'shared', and I linked the sample apps to the static library in the most dirty way possible. Keep in mind you still need have openssl installedHannigan
I
1

You can easily create a static library on Windows. Just set WITH_STATIC_LIB to ON during the cmake configure step.

NOTE: libssh is licensed under LGPL.

Ideal answered 21/11, 2011 at 14:12 Comment(0)
P
0

Additionally make sure to use libssh version-0.5.0 or older for building a VS2010 application as the newer libssh versions need VS2012.

Prochora answered 27/4, 2015 at 3:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.