[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: static cross-compiling


I'm sorry, I forgot to mention that I did read
http://api.libssh.org/master/libssh_linking.html and tried to put
"#define LIBSSH_STATIC 1" and "#define LIBSSH_STATIC" before my
include libssh line but it didn't seem to make a difference..?

Ah. okey. I've found this link now:
https://stackoverflow.com/questions/21083052/cross-compiling-for-arm-while-linking-to-libssh-libssh-so-file-not-recognized

So if that's correct I need to cross-compile libssh and it's
dependencies openssl and zlib for arm first, and can then using those
prepared arm lib binaries compile a static build of my program. I will
try to work on that next. Or have a look "embedded Linux distros like
Buildroot, OpenEmbedded or Embedded Debian Project" to see if I find
ready made arm binaries I can use?

2017-09-21 19:06 GMT+02:00 Thomas Käfer <kaefert@xxxxxxxxx>:
> Hello!
>
> I would like to write a program that I can cross-compile for Android
> and OpenWRT devices, that uses libssh to first talk to ssh servers and
> in a later development-stage to each other.
>
> Sadly, I'm not really too experienced in programming C / C++, so
> please bear with me.
>
> I found this tutorial
> http://jensd.be/800/linux/cross-compiling-for-arm-with-ubuntu-16-04-lts
> which with the additional install of the package "libc6-armel-cross"
> enabled me to cross-compile a program that prints "hello world" in a
> shell on my android device.
>
> Next step: After installing the package "libssh-dev" I was able to use
> sample code from
> http://api.libssh.org/master/libssh_tutor_guided_tour.html
> to compile a dynamically linked program that works on my Linux laptop.
>
> Now the step I have been struggling with for the last few hours is to
> compile this sample program that uses libssh in a static manner (and
> once that is accomplished doing so using the "arm-linux-gnueabi-gcc"
> cross-compiler)
>
> So I tried:
> $ gcc sshtest.c -static -lssh
> /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libssh.a(misc.c.o):
> In function `ssh_path_expand_tilde':
> (.text+0x87d): warning: Using 'getpwnam' in statically linked
> applications requires at runtime the shared libraries from the glibc
> version used for linking
> /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libssh.a(misc.c.o):
> In function `ssh_get_user_home_dir':
> (.text+0x3a): warning: Using 'getpwuid_r' in statically linked
> applications requires at runtime the shared libraries from the glibc
> version used for linking
> ...
> /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libssh.a(gssapi.c.o):
> In function `ssh_packet_userauth_gssapi_token_client':
> (.text+0x1b36): undefined reference to `gss_init_sec_context'
> /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libssh.a(gssapi.c.o):
> In function `ssh_packet_userauth_gssapi_token_client':
> (.text+0x1c20): undefined reference to `gss_get_mic'
> collect2: error: ld returned 1 exit status
>
> Then I downloaded the libssh source package and made a static build of
> the library using the ccmake gui to set the static parameter to true.
> With this I tried:
> $ gcc sshtest.c libssh-0.7.5/build/src/libssh.a -lssh
> libssh-0.7.5/build/src/libssh.a(curve25519.c.o): In function
> `ssh_curve25519_build_k':
> curve25519.c:(.text+0x13a): undefined reference to `BN_new'
> curve25519.c:(.text+0x1e9): undefined reference to `BN_bin2bn'
> libssh-0.7.5/build/src/libssh.a(dh.c.o): In function `ssh_get_random':
> ...
> libssh-0.7.5/build/src/libssh.a(bignum.c.o): In function `ssh_print_bignum':
> bignum.c:(.text+0x175): undefined reference to `BN_bn2hex'
> bignum.c:(.text+0x1dc): undefined reference to `CRYPTO_free'
> collect2: error: ld returned 1 exit status
>
>
> Now I'm out of ideas or in other words my googling skills are not
> sufficient to find new ones ;)
> Please help..
> Kind regards,
> Thomas K.

Follow-Ups:
RE: static cross-compilingJeremy Cross <JCross@xxxxxxxxxx>
References:
static cross-compilingThomas Käfer <kaefert@xxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org