libssh header einbinden



  • Hallo,

    ich arbeite mit Windows und möchte einen examplecode von der libssh-seite compilieren, dabei wird jedes Mal nach unistd.h und inttypes.h innerhalb der libssh.h gefragt, soweit ich das gelesen habe sind das linuxbasierende Headerdateien?

    #ifdef _MSC_VER
      /* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */
      typedef int int32_t;
      typedef unsigned int uint32_t;
      typedef unsigned short uint16_t;
      typedef unsigned char uint8_t;
      typedef unsigned long long uint64_t;
      typedef int mode_t;
    #else /* _MSC_VER */
      #include <unistd.h>
      #include <inttypes.h>
    #endif /* _MSC_VER */
    

    wie kann ich jetzt vorgehen?



  • Ist dein Code nicht bereits die Lösung? Verwendest du MinGW, sind die Header vorhanden, verwendest du MSVC, wird mithilfe des Präprozessors eine Alternative ausgeführt.



  • Ich habe jetzt Mingw ausprobiert, und mir das aktuelle release von libssh2.org geladen, mich beschleicht das Gefühl, als wenn mir da eine Library fehlt, kann das sein? Bei libssh2 habe ich keine finden können, brauche ich noch openssl dazu?

    C:\_test_environment\SunnyStuff\SSh2>gcc ssh2_exec.c -o test.exe
    C:\Users\brf24139\AppData\Local\Temp\cc2o2fky.o:ssh2_exec.c:(.text+0x93): undefined reference to li bssh2\_session\_block_directions' ... C:\\Users\\brf24139\\AppData\\Local\\Temp\\cc2o2fky.o:ssh2_exec.c:(.text+0x895): undefined reference toc
    losesocket@4'
    C:\Users\brf24139\AppData\Local\Temp\cc2o2fky.o:ssh2_exec.c:(.text+0x8c5): undefined reference to l ibssh2_exit' c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\\Users\\brf24139\\AppData\\Loca l\\Temp\\cc2o2fky.o: bad reloc address 0x20 in section.eh_frame'
    c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid ope
    ration
    collect2.exe: error: ld returned 1 exit status


  • Mod

    Das hat nichts mit den Headern zu tun, das sind Linkerfehler. Kein Wunder, denn gcc ssh2_exec.c -o test.exe linkt überhaupt gar nichts (außer der Standardbibliothek). Da fehlt die ssh-Bibliothek.



  • das hat mir schonmal weitergeholfen!

    mit gcc -LC:\MinGw\libssh-0.5.0\lib -LC:\MinGW\libssh-0.5.0\bin -IC:\MinGW\libssh-0.5.0\include example_ssh.c -o test.exe C:\MinGW\libssh-0.5.0\lib\SSH.lib -shared C:\MinGW\libssh-0.5.0\bin\ssh.dll

    wird eine Anwendung erstellt, leider kommt beim starten dieser "...test.exe is not a valid Win32 application" woran kann das liegen?


  • Mod

    ssh_trail schrieb:

    wird eine Anwendung erstellt, leider kommt beim starten dieser "...test.exe is not a valid Win32 application" woran kann das liegen?

    Von hier aus schwer zu sagen, aber vermutlich an einem dieser Gründe:
    Google: mingw is not a valid win32 application



  • Dieser Thread wurde von Moderator/in SeppJ aus dem Forum C (C89, C99 und C11) in das Forum Compiler- und IDE-Forum verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.



  • das gleiche Problem bei der TDM-MinGW Version für 32 und 64 bit, und an verschiedenen Rechnern, hat jemand einen Tip?



  • Hi ich habe es jetzt mit cygwin probiert, dort erscheint mir aber auf einmal vor jeder ssh-funktion ein __imp_ und diese funktion ist dann nirgends zu finden

    $ gcc example_ssh.c -o test.exe -IC:/MinGW/SSH_test
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x21): undefined reference to \_\_imp\_ssh\_is\_server\_known' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0x21): relocation truncated to fit: R\_X86\_64\_PC32 against undef ined symbol__imp_ssh_is_server_known'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x38): undefined reference to \_\_imp\_ssh\_get\_pubkey\_hash' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0x38): relocation truncated to fit: R\_X86\_64\_PC32 against undef ined symbol__imp_ssh_get_pubkey_hash'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0xc0): undefined reference to \_\_imp\_ssh\_print_hexa' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0xc0): relocation truncated to fit: R\_X86\_64\_PC32 against undef ined symbol__imp_ssh_print_hexa'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x1b1): undefined reference to \_\_imp\_ssh\_get_hexa' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0x1b1): relocation truncated to fit: R\_X86\_64\_PC32 against unde fined symbol__imp_ssh_get_hexa'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x27b): undefined reference to \_\_imp\_ssh\_write_knownhost' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0x27b): relocation truncated to fit: R\_X86\_64\_PC32 against unde fined symbol__imp_ssh_write_knownhost'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x2cd): undefined reference to \_\_imp\_ssh\_get_error' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0x2cd): relocation truncated to fit: R\_X86\_64\_PC32 against unde fined symbol__imp_ssh_get_error'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x333): undefined reference to \_\_imp\_ssh\_new' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0x333): relocation truncated to fit: R\_X86\_64\_PC32 against unde fined symbol__imp_ssh_new'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x364): undefined reference to \_\_imp\_ssh\_options_set' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0x364): relocation truncated to fit: R\_X86\_64\_PC32 against unde fined symbol__imp_ssh_options_set'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x374): undefined reference to \_\_imp\_ssh\_connect' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0x374): relocation truncated to fit: R\_X86\_64\_PC32 against unde fined symbol__imp_ssh_connect'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x38d): undefined reference to \_\_imp\_ssh\_get_error' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0x38d): relocation truncated to fit: R\_X86\_64\_PC32 against unde fined symbol__imp_ssh_get_error'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x3bb): undefined reference to `__imp_ssh_free'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x3bb): additional relocation overflows omitted from the output

    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x3e5): undefined reference to \_\_imp\_ssh\_disconnect' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0x3f5): undefined reference to__imp_ssh_free'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x42e): undefined reference to \_\_imp\_ssh\_userauth_password' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0x447): undefined reference to__imp_ssh_get_error'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x475): undefined reference to \_\_imp\_ssh\_disconnect' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0x485): undefined reference to__imp_ssh_free'
    /tmp/ccsN3pWf.o:example_ssh.c: (.text+0x4ab): undefined reference to \_\_imp\_ssh\_disconnect' /tmp/ccsN3pWf.o:example\_ssh.c: (.text+0x4bb): undefined reference to__imp_ssh_free'
    /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccsN3pWf.o: bad reloc
    address 0x210 in section `.rdata'
    /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/../../../../x86_64-pc-cygwin/bin/ld: final link failed: Invalid
    operation
    collect2: error: ld returned 1 exit status



  • keiner einen Tip? 😞


Anmelden zum Antworten