2

Anyone here have experienced libssh C++ wrapper yet? You can get here I'm using 0.6.3 version . I follow INSTALL instruction in downloaded file to build libraries.

Then I try to compile the example in examples directory libsshpp.cpp

#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.userauthAutopubkey();
    session.disconnect();
  } catch (ssh::SshException e){
    std::cout << "Error during connection : ";
    std::cout << e.getError() << std::endl;
  }
  return 0;
}

by command g++ -o sh libsshpp.cpp -lssh successed but when execute it take error : ./sh: symbol lookup error: ./sh: undefined symbol: ssh_userauth_publickey_auto. Hope who worked with libssh can help!

Nhan Ly
  • 95
  • 1
  • 4
  • 12
  • It's a bad idea to call your executable `sh`: That is the name of the system shell. – celtschk Apr 06 '14 at 22:15
  • I've tried another name but still get same error. – Nhan Ly Apr 06 '14 at 22:19
  • One thing which might happen is that the `ssh` installed in your system uses another version of the library which doesn't contain that symbol, and your program finds that one on execution. In which case you might be able to fix that with an appropriate `LD_LIBRARY_PATH` (but then, that may break the installed `ssh`). Another option would be to try static linking (at the cost of making your executable much bigger). – celtschk Apr 06 '14 at 22:26

0 Answers0