K
K
kennnies2019-04-02 21:32:41
linux
kennnies, 2019-04-02 21:32:41

How to compile cpp on linux with additional library?

mistake
$g++ -I. libsshpp.cpp -o libsshpp
/usr/bin/ld: /tmp/ccHZZCyj.o: in function `ssh::SshException::SshException(ssh_session_struct*)':
libsshpp.cpp:(.text._ZN3ssh12SshExceptionC2EP18ssh_session_struct[_ZN3ssh12SshExceptionC5EP18ssh_session_struct]+0x29): undefined reference to `ssh_get_error_code'
/usr/bin/ld: libsshpp.cpp:(.text._ZN3ssh12SshExceptionC2EP18ssh_session_struct[_ZN3ssh12SshExceptionC5EP18ssh_session_struct]+0x49): undefined reference to `ssh_get_error'
/usr/bin/ld: /tmp/ccHZZCyj.o: in function `ssh::Session::Session()':
libsshpp.cpp:(.text._ZN3ssh7SessionC2Ev[_ZN3ssh7SessionC5Ev]+0xd): undefined reference to `ssh_new'
/usr/bin/ld: /tmp/ccHZZCyj.o: in function `ssh::Session::~Session()':
libsshpp.cpp:(.text._ZN3ssh7SessionD2Ev[_ZN3ssh7SessionD5Ev]+0x17): undefined reference to `ssh_free'
/usr/bin/ld: /tmp/ccHZZCyj.o: in function `ssh::Session::setOption(ssh_options_e, char const*)':
libsshpp.cpp:(.text._ZN3ssh7Session9setOptionE13ssh_options_ePKc[_ZN3ssh7Session9setOptionE13ssh_options_ePKc]+0x2a): undefined reference to `ssh_options_set'
/usr/bin/ld: /tmp/ccHZZCyj.o: in function `ssh::Session::connect()':
libsshpp.cpp:(.text._ZN3ssh7Session7connectEv[_ZN3ssh7Session7connectEv]+0x1a): undefined reference to `ssh_connect'
/usr/bin/ld: /tmp/ccHZZCyj.o: in function `ssh::Session::userauthPublickeyAuto()':
libsshpp.cpp:(.text._ZN3ssh7Session21userauthPublickeyAutoEv[_ZN3ssh7Session21userauthPublickeyAutoEv]+0x24): undefined reference to `ssh_userauth_publickey_auto'
/usr/bin/ld: /tmp/ccHZZCyj.o: in function `ssh::Session::disconnect()':
libsshpp.cpp:(.text._ZN3ssh7Session10disconnectEv[_ZN3ssh7Session10disconnectEv]+0x17): undefined reference to `ssh_disconnect'
collect2: error: ld returned 1 exit status

downloaded the libssh library, tried to compile via g++/gcc with different options, successfully compiled c
-c libsshpp.cpp
, but it throws an error
bash: ./libsshpp: Permission denied
, I tried to give permissions through chmod, but nothing comes out either
bash: ./libsshpp: cannot execute binary file: Exec format error

x64 system, libsshpp is also x64, there are no problems with bitness. That just did not shake, nothing helps.
For the second day I can not solve the problem, wherever I threw these files, I installed the library itself via cmake. Tried on different systems (Parrot/Manjaro).
I hope for your help, because all my ideas are over and even the second page of Google did not help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rPman, 2019-04-02
@kennnies

https://rtfm.co.ua/c-libssh-primer-ssh-clienta/

gcc -lssh ssh_client_libssh1.c -o ssh_client_libssh1

D
Dmitry, 2019-04-06
@Compolomus

на убунте проверял

чтиво по флагам дял конфигурирования
https://github.com/libssh2/libssh2/blob/master/docs/INSTALL_AUTOTOOLS

sudo apt-get install gcc g++ pkg-config libncurses5-dev gawk build-essential autotools-dev bison re2c flex gperf libtool automake cmake

cd /home
sudo mkdir test
sudo chmod -R 777 test
wget https://www.libssh2.org/download/libssh2-1.8.2.tar.gz
sudo tar -xzf libssh2-1.8.2.tar.gz
cd libssh2-1.8.2
./buildconf
./configure
make
далее думаю разберетесь

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question