0

I'm trying to use libssh with C++ wrapper libsshpp.hpp ( It's wrapped from libssh.h, the libssh libraries written in C). At first I try to buld code from libsshpp.cpp in examples directory g++ -o sshpp libsshpp.cpp -lssh

#include <iostream>
#include <string>
#include <libssh/libsshpp.hpp>

int main(int argc, const char **argv){
  ssh::Session session;
  try {
    if(argc>1)
      session.setOption(SSH_OPTIONS_HOST,argv[1]);
    else
      session.setOption(SSH_OPTIONS_HOST,"localhost");
    session.connect();
    session.userauthPublickeyAuto();
    session.disconnect();
  } catch (ssh::SshException e){
    std::cout << "Error during connection : ";
    std::cout << e.getError() << std::endl;
  }
  return 0;
}

build is success but when excute sshpp, it shows error: ./sshpp: symbol lookup error: ./sshpp: undefined symbol: ssh_userauth_publickey_auto.

I look up in libsshpp.cpp:

  int userauthPublickeyAuto(void){
    int ret=ssh_userauth_publickey_auto(c_session, NULL, NULL);
    ssh_throw(ret);
    return ret;
  }

and in libssh.h:

LIBSSH_API int ssh_userauth_publickey_auto(ssh_session session,
                                           const char *username,
                                           const char *passphrase);

Hope anyone experienced with libssh can help

Nhan Ly
  • 95
  • 1
  • 4
  • 12

1 Answers1

0

"symbol lookup error" means the executable is looking for the object code for that method and cannot find it.

Try this: g++ -o sshpp libsshpp.cpp -L<"path to libssh"> -lssh

bluesky
  • 150
  • 1
  • 1
  • 11