libssh неопределенная ссылочная ошибка

Я пытаюсь создать пример соединения SSH и получаю неопределенные ссылки:

/tmp/ccb7VC9w.o: In function `verify_knownhost':
sshtest.c:(.text+0x3a): undefined reference to `ssh_get_server_publickey'
sshtest.c:(.text+0x91): undefined reference to `ssh_session_is_known_server'
collect2: error: ld returned 1 exit status

Я смотрел во включать файле на:

/usr/include/libssh/libssh.h

и найденный:

LIBSSH_API int ssh_get_server_publickey(ssh_session session, ssh_key *key);
LIBSSH_API enum ssh_known_hosts_e ssh_session_is_known_server(ssh_session session)

Я создал оба пути без успеха:

gcc -Wall -DLIBSSH_STATIC sshtest.c  -o sshtest  -lssh
gcc -Wall sshtest.c  -o sshtest  -lssh

Таким образом, мой вопрос... Я связываюсь неправильно, или я пропускаю некоторые шаги?

Сообщите мне, необходима ли минута жизнеспособный код.Спасибо!

Я поместил весь пример кода вместо просто немного... Проблема в функции, которой это называют от основного.:)

#include 
#include 
#include 
#include 
#include 


#define LIBSSH_STATIC 1


int verify_knownhost(ssh_session session)
{
    enum ssh_known_hosts_e state;
    unsigned char *hash = NULL;
    ssh_key srv_pubkey = NULL;
    size_t hlen;
    char buf[10];
    char *hexa;
    char *p;
    int cmp;
    int rc;
    rc = ssh_get_server_publickey(session, &srv_pubkey);
    if (rc < 0) {
        return -1;
    }
    rc = ssh_get_publickey_hash(srv_pubkey,
                                SSH_PUBLICKEY_HASH_SHA1,
                                &hash,
                                &hlen);
    ssh_key_free(srv_pubkey);
    if (rc < 0) {
        return -1;
    }
    state = ssh_session_is_known_server(session);
    switch (state) {
        case SSH_KNOWN_HOSTS_OK:
            /* OK */
            break;
        case SSH_KNOWN_HOSTS_CHANGED:
            fprintf(stderr, "Host key for server changed: it is now:\n");
            //ssh_print_hexa("Public key hash", hash, hlen);
            fprintf(stderr, "For security reasons, connection will be stopped\n");
            ssh_clean_pubkey_hash(&hash);
            return -1;
        case SSH_KNOWN_HOSTS_OTHER:
            fprintf(stderr, "The host key for this server was not found but an other"
                    "type of key exists.\n");
            fprintf(stderr, "An attacker might change the default server key to"
                    "confuse your client into thinking the key does not exist\n");
            ssh_clean_pubkey_hash(&hash);
            return -1;
        case SSH_KNOWN_HOSTS_NOT_FOUND:
            fprintf(stderr, "Could not find known host file.\n");
            fprintf(stderr, "If you accept the host key here, the file will be"
                    "automatically created.\n");
            /* FALL THROUGH to SSH_SERVER_NOT_KNOWN behavior */
        case SSH_KNOWN_HOSTS_UNKNOWN:
            hexa = ssh_get_hexa(hash, hlen);
            fprintf(stderr,"The server is unknown. Do you trust the host key?\n");
            fprintf(stderr, "Public key hash: %s\n", hexa);
            ssh_string_free_char(hexa);
            ssh_clean_pubkey_hash(&hash);
            p = fgets(buf, sizeof(buf), stdin);
            if (p == NULL) {
                return -1;
            }
            cmp = strncasecmp(buf, "yes", 3);
            if (cmp != 0) {
                return -1;
            }
            rc = ssh_get_status(session); //ssh_session_update_known_hosts(session);
            if (rc < 0) {
                fprintf(stderr, "Error %s\n", strerror(errno));
                return -1;
            }
            break;
        case SSH_KNOWN_HOSTS_ERROR:
            fprintf(stderr, "Error %s", ssh_get_error(session));
            ssh_clean_pubkey_hash(&hash);
            return -1;
    }
    ssh_clean_pubkey_hash(&hash);
    return 0;
}


int main()
{
  ssh_session my_ssh_session;
  int rc;
  char *password;
  // Open session and set options
  my_ssh_session = ssh_new();
  if (my_ssh_session == NULL)
    exit(-1);
  ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "localhost");
  // Connect to server
  rc = ssh_connect(my_ssh_session);
  if (rc != SSH_OK)
  {
    fprintf(stderr, "Error connecting to localhost: %s\n",
            ssh_get_error(my_ssh_session));
    ssh_free(my_ssh_session);
    exit(-1);
  }
  // Verify the server's identity
  // For the source code of verify_knownhost(), check previous example
  if (verify_knownhost(my_ssh_session) < 0)
  {
    ssh_disconnect(my_ssh_session);
    ssh_free(my_ssh_session);
    exit(-1);
  }
  // Authenticate ourselves
  password = getpass("Password: ");
  rc = ssh_userauth_password(my_ssh_session, NULL, password);
  if (rc != SSH_AUTH_SUCCESS)
  {
    fprintf(stderr, "Error authenticating with password: %s\n",
            ssh_get_error(my_ssh_session));
    ssh_disconnect(my_ssh_session);
    ssh_free(my_ssh_session);
    exit(-1);
  }


  ssh_disconnect(my_ssh_session);
  ssh_free(my_ssh_session);
}

Этот раздел содержит команду cmake и произвел это, я использовал.

cmake -DUNIT_TESTING=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ..
-- The C compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test REQUIRED_FLAGS_WERROR
-- Performing Test REQUIRED_FLAGS_WERROR - Success
-- Performing Test WITH_STD_GNU99_FLAG
-- Performing Test WITH_STD_GNU99_FLAG - Success
-- Performing Test WITH_WPEDANTIC_FLAG
-- Performing Test WITH_WPEDANTIC_FLAG - Success
-- Performing Test WITH_WALL_FLAG
-- Performing Test WITH_WALL_FLAG - Success
-- Performing Test WITH_WSHADOW_FLAG
-- Performing Test WITH_WSHADOW_FLAG - Success
-- Performing Test WITH_WMISSING_PROTOTYPES_FLAG
-- Performing Test WITH_WMISSING_PROTOTYPES_FLAG - Success
-- Performing Test WITH_WCAST_ALIGN_FLAG
-- Performing Test WITH_WCAST_ALIGN_FLAG - Success
-- Performing Test WITH_WERROR_ADDRESS_FLAG
-- Performing Test WITH_WERROR_ADDRESS_FLAG - Success
-- Performing Test WITH_WSTRICT_PROTOTYPES_FLAG
-- Performing Test WITH_WSTRICT_PROTOTYPES_FLAG - Success
-- Performing Test WITH_WERROR_STRICT_PROTOTYPES_FLAG
-- Performing Test WITH_WERROR_STRICT_PROTOTYPES_FLAG - Success
-- Performing Test WITH_WWRITE_STRINGS_FLAG
-- Performing Test WITH_WWRITE_STRINGS_FLAG - Success
-- Performing Test WITH_WERROR_WRITE_STRINGS_FLAG
-- Performing Test WITH_WERROR_WRITE_STRINGS_FLAG - Success
-- Performing Test WITH_WERROR_IMPLICIT_FUNCTION_DECLARATION_FLAG
-- Performing Test WITH_WERROR_IMPLICIT_FUNCTION_DECLARATION_FLAG - Success
-- Performing Test WITH_WPOINTER_ARITH_FLAG
-- Performing Test WITH_WPOINTER_ARITH_FLAG - Success
-- Performing Test WITH_WERROR_POINTER_ARITH_FLAG
-- Performing Test WITH_WERROR_POINTER_ARITH_FLAG - Success
-- Performing Test WITH_WDECLARATION_AFTER_STATEMENT_FLAG
-- Performing Test WITH_WDECLARATION_AFTER_STATEMENT_FLAG - Success
-- Performing Test WITH_WERROR_DECLARATION_AFTER_STATEMENT_FLAG
-- Performing Test WITH_WERROR_DECLARATION_AFTER_STATEMENT_FLAG - Success
-- Performing Test WITH_WRETURN_TYPE_FLAG
-- Performing Test WITH_WRETURN_TYPE_FLAG - Success
-- Performing Test WITH_WERROR_RETURN_TYPE_FLAG
-- Performing Test WITH_WERROR_RETURN_TYPE_FLAG - Success
-- Performing Test WITH_WUNINITIALIZED_FLAG
-- Performing Test WITH_WUNINITIALIZED_FLAG - Success
-- Performing Test WITH_WERROR_UNINITIALIZED_FLAG
-- Performing Test WITH_WERROR_UNINITIALIZED_FLAG - Success
-- Performing Test WITH_WIMPLICIT_FALLTHROUGH_FLAG
-- Performing Test WITH_WIMPLICIT_FALLTHROUGH_FLAG - Failed
-- Performing Test WITH_WERROR_STRICT_OVERFLOW_FLAG
-- Performing Test WITH_WERROR_STRICT_OVERFLOW_FLAG - Success
-- Performing Test WITH_WSTRICT_OVERFLOW_2_FLAG
-- Performing Test WITH_WSTRICT_OVERFLOW_2_FLAG - Success
-- Performing Test WITH_WNO_FORMAT_ZERO_LENGTH_FLAG
-- Performing Test WITH_WNO_FORMAT_ZERO_LENGTH_FLAG - Success
-- Performing Test WITH_WMISSING_FIELD_INITIALIZERS_FLAG
-- Performing Test WITH_WMISSING_FIELD_INITIALIZERS_FLAG - Success
-- Performing Test REQUIRED_FLAGS_WFORMAT
-- Performing Test REQUIRED_FLAGS_WFORMAT - Success
-- Performing Test WITH_WFORMAT_SECURITY_FLAG
-- Performing Test WITH_WFORMAT_SECURITY_FLAG - Success
-- Performing Test WITH_WERROR_FORMAT_SECURITY_FLAG
-- Performing Test WITH_WERROR_FORMAT_SECURITY_FLAG - Success
-- Performing Test WITH_FNO_COMMON_FLAG
-- Performing Test WITH_FNO_COMMON_FLAG - Success
-- Performing Test WITH_STACK_PROTECTOR_STRONG
-- Performing Test WITH_STACK_PROTECTOR_STRONG - Success
-- Performing Test WITH_STACK_CLASH_PROTECTION
-- Performing Test WITH_STACK_CLASH_PROTECTION - Failed
-- Performing Test WITH_WNO_DEPRECATED_DECLARATIONS_FLAG
-- Performing Test WITH_WNO_DEPRECATED_DECLARATIONS_FLAG - Success
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8") 
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.0.2g") 
-- Found CMocka: /usr/lib/x86_64-linux-gnu/libcmocka.so  
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'heimdal-gssapi'
--   No package 'heimdal-gssapi' found
-- Could NOT find GSSAPI (missing:  GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIR) 
-- Could NOT find NaCl (missing:  NACL_LIBRARIES NACL_INCLUDE_DIRS) 
-- Found PythonInterp: /usr/bin/python (found version "2.7.12") 
-- Could not find `abimap` in PATH. It can be found in PyPI as `abimap` (try `pip install abimap`)
-- Could NOT find ABIMap (missing:  ABIMAP_EXECUTABLE) (Required is at least version "0.3.1")
-- Performing Test WITH_VISIBILITY_HIDDEN
-- Performing Test WITH_VISIBILITY_HIDDEN - Success
-- Looking for argp.h
-- Looking for argp.h - found
-- Looking for pty.h
-- Looking for pty.h - found
-- Looking for utmp.h
-- Looking for utmp.h - found
-- Looking for termios.h
-- Looking for termios.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for util.h
-- Looking for util.h - not found
-- Looking for libutil.h
-- Looking for libutil.h - not found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for sys/utime.h
-- Looking for sys/utime.h - not found
-- Looking for sys/param.h
-- Looking for sys/param.h - found
-- Looking for arpa/inet.h
-- Looking for arpa/inet.h - found
-- Looking for byteswap.h
-- Looking for byteswap.h - found
-- Looking for glob.h
-- Looking for glob.h - found
-- Looking for valgrind/valgrind.h
-- Looking for valgrind/valgrind.h - found
-- Looking for openssl/des.h
-- Looking for openssl/des.h - found
-- Looking for openssl/aes.h
-- Looking for openssl/aes.h - found
-- Looking for openssl/ecdh.h
-- Looking for openssl/ecdh.h - found
-- Looking for openssl/ec.h
-- Looking for openssl/ec.h - found
-- Looking for openssl/ecdsa.h
-- Looking for openssl/ecdsa.h - found
-- Looking for EVP_aes_128_ctr
-- Looking for EVP_aes_128_ctr - found
-- Looking for EVP_aes_128_cbc
-- Looking for EVP_aes_128_cbc - found
-- Looking for EVP_aes_128_gcm
-- Looking for EVP_aes_128_gcm - found
-- Looking for CRYPTO_THREADID_set_callback
-- Looking for CRYPTO_THREADID_set_callback - found
-- Looking for CRYPTO_ctr128_encrypt
-- Looking for CRYPTO_ctr128_encrypt - found
-- Looking for EVP_CIPHER_CTX_new
-- Looking for EVP_CIPHER_CTX_new - found
-- Looking for EVP_KDF_CTX_new_id
-- Looking for EVP_KDF_CTX_new_id - not found
-- Looking for RAND_priv_bytes
-- Looking for RAND_priv_bytes - not found
-- Looking for OPENSSL_ia32cap_loc
-- Looking for OPENSSL_ia32cap_loc - found
-- Looking for isblank
-- Looking for isblank - found
-- Looking for strncpy
-- Looking for strncpy - found
-- Looking for strndup
-- Looking for strndup - found
-- Looking for strtoull
-- Looking for strtoull - found
-- Looking for explicit_bzero
-- Looking for explicit_bzero - not found
-- Looking for memset_s
-- Looking for memset_s - not found
-- Performing Test HAVE_GLOB_GL_FLAGS_MEMBER
-- Performing Test HAVE_GLOB_GL_FLAGS_MEMBER - Success
-- Looking for glob
-- Looking for glob - found
-- Looking for vsnprintf
-- Looking for vsnprintf - found
-- Looking for snprintf
-- Looking for snprintf - found
-- Looking for poll
-- Looking for poll - found
-- Looking for select
-- Looking for select - found
-- Looking for getaddrinfo
-- Looking for getaddrinfo - found
-- Looking for ntohll
-- Looking for ntohll - not found
-- Looking for htonll
-- Looking for htonll - not found
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- Looking for forkpty in util
-- Looking for forkpty in util - found
-- Looking for cfmakeraw
-- Looking for cfmakeraw - found
-- Looking for __strtoull
-- Looking for __strtoull - not found
-- Looking for cmocka_set_test_filter
-- Looking for cmocka_set_test_filter - found
-- Performing Test HAVE_GCC_THREAD_LOCAL_STORAGE
-- Performing Test HAVE_GCC_THREAD_LOCAL_STORAGE - Success
-- Performing Test HAVE_MSC_THREAD_LOCAL_STORAGE
-- Performing Test HAVE_MSC_THREAD_LOCAL_STORAGE - Failed
-- Performing Test HAVE_CONSTRUCTOR_ATTRIBUTE
-- Performing Test HAVE_CONSTRUCTOR_ATTRIBUTE - Success
-- Performing Test HAVE_DESTRUCTOR_ATTRIBUTE
-- Performing Test HAVE_DESTRUCTOR_ATTRIBUTE - Success
-- Performing Test HAVE_FALLTHROUGH_ATTRIBUTE
-- Performing Test HAVE_FALLTHROUGH_ATTRIBUTE - Failed
-- Performing Test HAVE_UNUSED_ATTRIBUTE
-- Performing Test HAVE_UNUSED_ATTRIBUTE - Success
-- Performing Test HAVE_GCC_VOLATILE_MEMORY_PROTECTION
-- Performing Test HAVE_GCC_VOLATILE_MEMORY_PROTECTION - Success
-- Performing Test HAVE_COMPILER__FUNC__
-- Performing Test HAVE_COMPILER__FUNC__ - Success
-- Performing Test HAVE_COMPILER__FUNCTION__
-- Performing Test HAVE_COMPILER__FUNCTION__ - Success
-- Performing Test HAVE_LD_VERSION_SCRIPT
-- Performing Test HAVE_LD_VERSION_SCRIPT - Success
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Threads_FOUND=TRUE
-- The CXX compiler identification is GNU 5.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- ********************************************
-- ********** libssh build options : **********
-- zlib support: ON
-- libgcrypt support: OFF
-- libmbedTLS support: OFF
-- libnacl support: OFF
-- SFTP support: ON
-- Server support : ON
-- GSSAPI support : 0
-- GEX support : ON
-- Pcap debugging support : ON
-- With static library: OFF
-- Unit testing: ON
-- Client code testing: OFF
-- Blowfish cipher support: OFF
-- Server code testing: OFF
-- Public API documentation generation
-- Benchmarks: OFF
-- Symbol versioning: ON
-- Allow ABI break: OFF
-- Release is final: 
-- Global client config: /etc/ssh/ssh_config
-- Global bind config: /etc/ssh/libssh_server_config
-- ********************************************
-- Configuring done
-- Generating done
-- Build files have been written to: /home/me/Downloads/libssh-0.9.0 (2)/build

Этот раздел содержит сделать команду и вывод:

 make
Scanning dependencies of target ssh_static
[  1%] Building C object src/CMakeFiles/ssh_static.dir/agent.c.o
[  1%] Building C object src/CMakeFiles/ssh_static.dir/auth.c.o
[  1%] Building C object src/CMakeFiles/ssh_static.dir/base64.c.o
[  2%] Building C object src/CMakeFiles/ssh_static.dir/bignum.c.o
[  2%] Building C object src/CMakeFiles/ssh_static.dir/buffer.c.o
[  3%] Building C object src/CMakeFiles/ssh_static.dir/callbacks.c.o
[  3%] Building C object src/CMakeFiles/ssh_static.dir/channels.c.o
[  3%] Building C object src/CMakeFiles/ssh_static.dir/client.c.o
[  4%] Building C object src/CMakeFiles/ssh_static.dir/config.c.o
[  4%] Building C object src/CMakeFiles/ssh_static.dir/connect.c.o
[  5%] Building C object src/CMakeFiles/ssh_static.dir/connector.c.o
[  5%] Building C object src/CMakeFiles/ssh_static.dir/curve25519.c.o
[  5%] Building C object src/CMakeFiles/ssh_static.dir/dh.c.o
[  6%] Building C object src/CMakeFiles/ssh_static.dir/ecdh.c.o
[  6%] Building C object src/CMakeFiles/ssh_static.dir/error.c.o
[  7%] Building C object src/CMakeFiles/ssh_static.dir/getpass.c.o
[  7%] Building C object src/CMakeFiles/ssh_static.dir/init.c.o
[  7%] Building C object src/CMakeFiles/ssh_static.dir/kdf.c.o
[  8%] Building C object src/CMakeFiles/ssh_static.dir/kex.c.o
[  8%] Building C object src/CMakeFiles/ssh_static.dir/known_hosts.c.o
[  8%] Building C object src/CMakeFiles/ssh_static.dir/knownhosts.c.o
[  9%] Building C object src/CMakeFiles/ssh_static.dir/legacy.c.o
[  9%] Building C object src/CMakeFiles/ssh_static.dir/log.c.o
[ 10%] Building C object src/CMakeFiles/ssh_static.dir/match.c.o
[ 10%] Building C object src/CMakeFiles/ssh_static.dir/messages.c.o
[ 10%] Building C object src/CMakeFiles/ssh_static.dir/misc.c.o
[ 11%] Building C object src/CMakeFiles/ssh_static.dir/options.c.o
[ 11%] Building C object src/CMakeFiles/ssh_static.dir/packet.c.o
[ 12%] Building C object src/CMakeFiles/ssh_static.dir/packet_cb.c.o
[ 12%] Building C object src/CMakeFiles/ssh_static.dir/packet_crypt.c.o
[ 12%] Building C object src/CMakeFiles/ssh_static.dir/pcap.c.o
[ 13%] Building C object src/CMakeFiles/ssh_static.dir/pki.c.o
[ 13%] Building C object src/CMakeFiles/ssh_static.dir/pki_container_openssh.c.o
[ 14%] Building C object src/CMakeFiles/ssh_static.dir/pki_ed25519.c.o
[ 14%] Building C object src/CMakeFiles/ssh_static.dir/poll.c.o
[ 14%] Building C object src/CMakeFiles/ssh_static.dir/session.c.o
[ 15%] Building C object src/CMakeFiles/ssh_static.dir/scp.c.o
[ 15%] Building C object src/CMakeFiles/ssh_static.dir/socket.c.o
[ 16%] Building C object src/CMakeFiles/ssh_static.dir/string.c.o
[ 16%] Building C object src/CMakeFiles/ssh_static.dir/threads.c.o
[ 16%] Building C object src/CMakeFiles/ssh_static.dir/wrapper.c.o
[ 17%] Building C object src/CMakeFiles/ssh_static.dir/external/bcrypt_pbkdf.c.o
[ 17%] Building C object src/CMakeFiles/ssh_static.dir/external/blowfish.c.o
[ 18%] Building C object src/CMakeFiles/ssh_static.dir/external/chacha.c.o
[ 18%] Building C object src/CMakeFiles/ssh_static.dir/external/ed25519.c.o
[ 18%] Building C object src/CMakeFiles/ssh_static.dir/external/fe25519.c.o
[ 19%] Building C object src/CMakeFiles/ssh_static.dir/external/ge25519.c.o
[ 19%] Building C object src/CMakeFiles/ssh_static.dir/external/poly1305.c.o
[ 19%] Building C object src/CMakeFiles/ssh_static.dir/external/sc25519.c.o
[ 20%] Building C object src/CMakeFiles/ssh_static.dir/chachapoly.c.o
[ 20%] Building C object src/CMakeFiles/ssh_static.dir/config_parser.c.o
[ 21%] Building C object src/CMakeFiles/ssh_static.dir/token.c.o
[ 21%] Building C object src/CMakeFiles/ssh_static.dir/threads/noop.c.o
[ 21%] Building C object src/CMakeFiles/ssh_static.dir/threads/pthread.c.o
[ 22%] Building C object src/CMakeFiles/ssh_static.dir/threads/libcrypto.c.o
[ 22%] Building C object src/CMakeFiles/ssh_static.dir/pki_crypto.c.o
[ 23%] Building C object src/CMakeFiles/ssh_static.dir/ecdh_crypto.c.o
[ 23%] Building C object src/CMakeFiles/ssh_static.dir/libcrypto.c.o
In file included from /home/me/Downloads/libssh-0.9.0 (2)/src/libcrypto.c:31:0:
/home/me/Downloads/libssh-0.9.0 (2)/include/libssh/priv.h:400:22: error: expected ‘)’ before ‘__attribute__’
 #  define __unused__ __attribute__((unused))
                      ^
In file included from /home/me/Downloads/libssh-0.9.0 (2)/src/libcrypto.c:59:0:
/usr/include/valgrind/valgrind.h:6753:56: error: expected ‘,’ or ‘;’ before ‘)’ token
    __attribute__((format(__printf__, 1, 2), __unused__));
                                                        ^
In file included from /home/me/Downloads/libssh-0.9.0 (2)/src/libcrypto.c:31:0:
/home/me/Downloads/libssh-0.9.0 (2)/include/libssh/priv.h:400:22: error: expected ‘)’ before ‘__attribute__’
 #  define __unused__ __attribute__((unused))
                      ^
In file included from /home/me/Downloads/libssh-0.9.0 (2)/src/libcrypto.c:59:0:
/usr/include/valgrind/valgrind.h:6791:56: error: expected ‘,’ or ‘;’ before ‘)’ token
    __attribute__((format(__printf__, 1, 2), __unused__));
                                                        ^
src/CMakeFiles/ssh_static.dir/build.make:1430: recipe for target 'src/CMakeFiles/ssh_static.dir/libcrypto.c.o' failed
make[2]: *** [src/CMakeFiles/ssh_static.dir/libcrypto.c.o] Error 1
CMakeFiles/Makefile2:1069: recipe for target 'src/CMakeFiles/ssh_static.dir/all' failed
make[1]: *** [src/CMakeFiles/ssh_static.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

3
задан 21 October 2019 в 17:18

1 ответ

Удаленный openssh и libssh-dev и собирающийся пробовать установку снова:

sudo apt-get remove --purge openssh-server  libssh-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  ncurses-term openssh-sftp-server ssh-import-id
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  libssh-dev* openssh-server*
0 upgraded, 0 newly installed, 2 to remove and 3 not upgraded.
After this operation, 1,706 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 453549 files and directories currently installed.)
Removing libssh-dev (0.6.3-4.3ubuntu0.2) ...
dpkg: warning: while removing libssh-dev, directory '/usr/include/libssh' not empty so not removed
Removing openssh-server (1:7.2p2-4ubuntu2.8) ...
Purging configuration files for openssh-server (1:7.2p2-4ubuntu2.8) ...
Processing triggers for man-db (2.7.5-1) ...

Удостоверенный, что пакеты были удалены:

sudo apt-get clean
sudo apt-get autoclean

dpkg-query --list  | grep -i ssh
ii  libjsch-java                                                0.1.53-1ubuntu1                               all          Java implementation of the SSH2 protocol
ii  libssh-4:amd64                                              0.6.3-4.3ubuntu0.2                            amd64        tiny C SSH library (OpenSSL flavor)
ii  libssh-gcrypt-4:amd64                                       0.6.3-4.3ubuntu0.2                            amd64        tiny C SSH library (gcrypt flavor)
ii  openssh-client                                              1:7.2p2-4ubuntu2.8                            amd64        secure shell (SSH) client, for secure access to remote machines
ii  openssh-sftp-server                                         1:7.2p2-4ubuntu2.8                            amd64        secure shell (SSH) sftp server module, for SFTP access from remote machines
ii  ssh-import-id                                               5.5-0ubuntu1                                  all          securely retrieve an SSH public key and install it locally
ii  sshpass                                                     1.05-1                                        amd64        Non-interactive ssh password authentication

/usr/include/libssh$ ls
libsshpp.hpp

Проверенный gcc не мог скомпилировать ни с каким свисанием ssh, освобождает:

gcc -Wall $(pkg-config --cflags libssh) sshtest.c -o sshtest $(pkg-config --libs libssh)
sshtest.c:1:27: fatal error: libssh/libssh.h: No such file or directory
compilation terminated.

Новая установка openssh и libssh-dev:

sudo apt-get install openssh-server libssh-dev build-essential

И теперь все работает. Я предполагаю что autoclean и т.д., возможно, удалил некоторые пакеты, которые свисали вокруг, и установка была, правильно покончили apt-get.

gcc -Wall  sshtest.c  -o sshtest -lssh -DLIBSSH_STATIC
./sshtest tet.txt 
tst

Я хотел бы сказать спасибо всем Вам для помощи мне. Без Вашего руководства я не понял бы это.:)

2
ответ дан 1 December 2019 в 16:49

Другие вопросы по тегам:

Похожие вопросы: