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;
}