LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Odd runtime error, undefined symbol: ssh_channel_new (https://www.linuxquestions.org/questions/programming-9/odd-runtime-error-undefined-symbol-ssh_channel_new-922056/)

mfziegler 01-04-2012 02:38 PM

Odd runtime error, undefined symbol: ssh_channel_new
 
Hey all,

I'm writing a simple c++ program with libssh (http://www.libssh.org/) that will create an ssh connection with my samba server, and then create a user with an inputted username and password.

My program compiles with no errors or warnings, and it executes the first several functions from the libssh library without any problems; however, when my program tries to execute the ssh_channel_new command, I get the run time error: ./myProgram: symbol lookup error: ./myProgram: undefined symbol: ssh_channel_new

I'm using a makefile generated from QT's qmake, and added -lssh to the LIBS option line.

Here is the code leading up to the error, most of it is copied from the libssh examples, so I really don't know what could be going wrong. Any help would be greatly appreciated :)

Code:

ssh_session ssh;
  ssh = ssh_new();
  if (ssh == NULL) {
      cout << "ssh session could not be initialized";
      ssh_free(ssh);
      return;
  }
 
  ssh_options_set(ssh, SSH_OPTIONS_HOST, IP);
  ssh_options_set(ssh, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
  ssh_options_set(ssh, SSH_OPTIONS_PORT, &port);
  ssh_options_set(ssh, SSH_OPTIONS_USER, user);
 
  cout << "Connecting to server..." << endl;
  rc = ssh_connect(ssh);
  if (rc != SSH_OK) {
      cout << "Could not connect to server.";
      ssh_free(ssh);
      return;
  }
 
  if (verify_knownhost(ssh) != 0) {
      cout << "Could not verify known host.";
      ssh_disconnect(ssh);
      ssh_free(ssh);
      return;
  }
 
  rc = ssh_userauth_password(ssh, NULL, adminPass);
  if (rc != SSH_AUTH_SUCCESS) {
      cout << "server admin password not accepted.";
      ssh_disconnect(ssh);
      ssh_free(ssh);
      return;
  }
 
  cout << "Connected." << endl;
  ssh_channel channel;
 
  cout << "Creating ssh channel..." << endl;
  channel = ssh_channel_new(ssh);
  if (channel == NULL) {
      cout << "Could not establish channel.";
      ssh_disconnect(ssh);
      ssh_free(ssh);
      return;
  }


RudyMartin 01-07-2012 08:17 PM

is there a linker reference missing perhaps?

http://api.libssh.org/master/libssh_linking.html

wtruong 01-11-2012 02:25 PM

Where is your libssh.so file located at, relative to your binary?

mfziegler 01-11-2012 02:41 PM

I figured out the problem. Apparently when I installed the libssh libraries, it was not a complete installation and therefore I got these errors. It just confused me because I figured that the program wouldn't even compile if it was missing some of the files. Anyway, thank you all for trying to help! :)


All times are GMT -5. The time now is 05:30 AM.