Subject: Windows and libssh2 not working

Windows and libssh2 not working

From: Phillip Wu <Phillip.Wu_at_lpma.nsw.gov.au>
Date: Wed, 1 Dec 2010 12:27:46 +1100

Thanks for the info.

I am new to Visual Studio C++ development.
But from what I read dynamic linking means calls to the dll is resolved at run time and
implicit/static linking is resolved at compile time. Does this mean if I use implicit linking and
the location of the dll changes then I need to recompile my client program?

I tried implicit linking:
1. I downloaded the libssh2.dll (version 1.2.7), libgcrypt.dll, libgpg-error.dll
2. I created *.obj for libssh2 using MSDN document "How To Create 32-bit Import Libraries Without .OBJs or Source"
   This is a dummy *.obj file used to tell the linker about the calls in the dll.
3. I wrote a very simple client program based on MSDN socket program:
   sock=ssh_connection(host)); /* Creates socket to host */
   session = libssh2_session_init();
   if (status=libssh2_session_startup(session, sock)) exit(0);
   userauthlist = libssh2_userauth_list(session, username, strlen(username));

However userauthlist is empty. If I run the same program (replacing the socket creation part) on my Redhat Linux system
with the same user it works fine. This is the trace from openssh:
Server listening on 0.0.0.0 port 2022.
socket: Address family not supported by protocol
debug3: fd 4 is not O_NONBLOCK
debug1: Server will not fork when running in debugging mode.
debug3: send_rexec_state: entering fd = 7 config len 350
debug3: ssh_msg_send: type 0
debug3: send_rexec_state: done
debug1: rexec start in 4 out 4 newsock 4 pipe -1 sock 7
debug3: recv_rexec_state: entering fd = 5
debug3: ssh_msg_recv entering
debug3: recv_rexec_state: done
debug2: parse_server_config: config rexec len 350
debug3: rexec:13 setting Port 22
debug3: rexec:19 setting Protocol 2
debug3: rexec:33 setting SyslogFacility AUTH
debug3: rexec:34 setting LogLevel INFO
debug3: rexec:59 setting PasswordAuthentication yes
debug3: rexec:63 setting ChallengeResponseAuthentication yes
debug3: rexec:90 setting X11Forwarding yes
debug3: rexec:112 setting Subsystem sftp /home/myuser/openssh/libexec/sftp-server
debug3: rexec:113 setting Subsystem sua /home/myuser/openssh/libexec/sftp-server
debug1: sshd version OpenSSH_5.5p1
debug3: Not a RSA1 key file /home/myuser/openssh/ssh/ssh_host_rsa_key.
debug1: read PEM private key done: type RSA
debug1: private host key: #0 type 1 RSA
debug3: Not a RSA1 key file /home/myuser/openssh/ssh/ssh_host_dsa_key.
debug1: read PEM private key done: type DSA
debug1: private host key: #1 type 2 DSA
debug1: setgroups() failed: Operation not permitted
debug1: inetd sockets after dupping: 3, 3
Connection from 10.1.8.1 port 5408
Did not receive identification string from 10.1.8.1

Questions
=========
1. Can someone spot what is wrong?
2. libssh2.dll calls routines in libgcrypt.dll which in turn calls routines in libgpg-error.dll.
 Do I need to do anything special with *.obj for libssh2 to tell Windows about this?

-----Original Message-----
From: libssh2-devel-bounces_at_cool.haxx.se [mailto:libssh2-devel-bounces_at_cool.haxx.se] On Behalf Of Mark Riordan
Sent: Friday, 19 November 2010 9:35 AM
To: 'libssh2 development'
Subject: RE: Windows and libssh2

Phillip wrote:
> 1. Has anyone used (dynamic linking) for libssh2?
> If so, is there somewhere I can get the code stubs for
> all the libssh2 functions (perhaps as a "define")?

I haven't done it, but it should be reasonably straightforward.
I'm assuming you have a specific reason for dynamically linking...

> 2. When I try to compile ssh2 example it is unable to find:
> closesocket (etc.)
> Does anyone know which dll on Windows have these system calls?

WSock32.dll

> 3. Would I be better off using MinGW or some other
> build package for Windows?

I've used VC 2008 with libssh2 and it worked well.
I've found VC 2010 to be pretty similar, so it should work equally well.
MinGW would probably only complicate things.
You can take a look at the VC 2008 .vcproj file for my libssh2 sample at:
http://trac.libssh2.org/attachment/ticket/197/sftpmrr.zip

Mark

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

***************************************************************
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-12-01