Subject: Windows and libssh2

Windows and libssh2

From: Phillip Wu <Phillip.Wu_at_lpma.nsw.gov.au>
Date: Fri, 19 Nov 2010 09:15:00 +1100

Hi,

I am trying to use libssh2 in Visual Studio 2010 Express C++. I am using ssh2 from the example directory.

I managed to get libssh2 (version 1.2.7) for Windows as a dll from http://josefsson.org/gnutls4win/.

According to MSDN this is the required code to get access to a dll at run time:
>>
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;

    // Get a handle to the DLL module.

    hinstLib = LoadLibrary(TEXT("libssh2-1.dll"));

    // If the handle is valid, try to get the function address.

    if (hinstLib != NULL)
    {
        ProcAdd = (MYPROC) GetProcAddress(hinstLib, "libssh2_session_init");

        // If the function address is valid, call the function.

        if (NULL != ProcAdd)
        {
            fRunTimeLinkSuccess = TRUE;
            (ProcAdd) ();
        }
        // Free the DLL module.

        fFreeResult = FreeLibrary(hinstLib);
    }

    // If unable to call the DLL function, use an alternative.
    if (! fRunTimeLinkSuccess)
        printf("Unable to access Dynamic Library libssh2-1.dll or routine libssh2_session_init\n");
<<

1. Has anyone used this approach for libssh2? If so, is there somewhere I can get the code stubs for
all the libssh2 functions (perhaps as a "define")?
2. When I try to compile ssh2 example it is unable to find:
closesocket
socket
connect
htons
htonl
inet_addr
WSAStartup
Does anyone know which dll on Windows have these system calls?
3. Would I be better off using MinGW or some other build package for Windows?

***************************************************************
This message is intended for the addressee named and may contain confidential information. If you are not the intended recipient, please delete it and notify the sender. Views expressed in this message are those of the individual sender, and are not necessarily the views of the Land and Property Management Authority. This email message has been swept by MIMEsweeper for the presence of computer viruses.
***************************************************************
Please consider the environment before printing this email.

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-11-18