Hello,
I have built libssh2 and its dependencies for aarch64, in such a way to
link these libs as static into the final executable.
So the dependencies compiled as static libraries are
*libassuan.a
libcrypto.a
libgcrypt.a
libgpg-error.a
libksba.a
libnpth.a
libntbtls.a
libssl.a
libz.a*
To test the static linkage I use the following minimal code:
// libssh2_test.c
#include <libssh2.h>
int main(void)
{
LIBSSH2_SESSION *session;
LIBSSH2_CHANNEL *channel;
libssh2_init(0);
session = libssh2_session_init();
libssh2_session_free(session);
libssh2_exit();
return 0;
}
But when I try to compile, ld cannot find libssh2 symbols:
*aarch64-linux-gnu-gcc -I ../third/include/ ../third/lib/libz.a
../third/lib/libnpth.a ../third/lib/libssl.a ../third/lib/libcrypto.a
../third/lib/libgpg-error.a ../third/lib/libksba.a
../third/lib/libgcrypt.a ../third/lib/libntbtls.a
../third/lib/libassuan.a ../third/lib/libssh2.a libssh2_test.c -o
libssh2_test
/opt/Xilinx/Vitis/2019.2/gnu/aarch64/lin/aarch64-linux/bin/../lib/gcc/aarch64-linux-gnu/8.2.0/../../../../aarch64-linux-gnu/bin/ld:
/tmp/ccSuPNUb.o: in function `main':
libssh2_test.c:(.text+0xc): undefined reference to `libssh2_init'
/opt/Xilinx/Vitis/2019.2/gnu/aarch64/lin/aarch64-linux/bin/../lib/gcc/aarch64-linux-gnu/8.2.0/../../../../aarch64-linux-gnu/bin/ld:
libssh2_test.c:(.text+0x20): undefined reference to
`libssh2_session_init_ex'
/opt/Xilinx/Vitis/2019.2/gnu/aarch64/lin/aarch64-linux/bin/../lib/gcc/aarch64-linux-gnu/8.2.0/../../../../aarch64-linux-gnu/bin/ld:
libssh2_test.c:(.text+0x2c): undefined reference to `libssh2_session_free'
/opt/Xilinx/Vitis/2019.2/gnu/aarch64/lin/aarch64-linux/bin/../lib/gcc/aarch64-linux-gnu/8.2.0/../../../../aarch64-linux-gnu/bin/ld:
libssh2_test.c:(.text+0x30): undefined reference to `libssh2_exit'
collect2: error: ld returned 1 exit status*
Of course these functions are defined in libssh2.h.
libssh2 has been compiled using the following script:
*#!/bin/sh
host=aarch64
target=aarch64-linux-gnu
cc=${target}-gcc
cpp=${target}-g++
ar=${target}-ar
cross_path=/opt/Xilinx/Vitis/2019.2/gnu/aarch64/lin/aarch64-linux/bin
install_prefix=${PWD}/../../../third/
../configure --prefix=${install_prefix} \
--host=${host} \
CC=${cross_path}/${cc} \
CXX=${cross_path}/${cpp} \
--with-gnu-ld \
--with-libgpg-error-prefix=${install_prefix} \
--with-crypto=auto \
--with-libgcrypt-prefix=${install_prefix} \
--with-libssl-prefix=${install_prefix} \
--enable-static \
--enable-shared
if [ $? -eq 0 ]; then
make -j 32
make install
fi*
Could someone suggest what I have done wrong ?
Thanks.
S.
_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2020-09-24