I working on a RedHat system.
我正在研究RedHat系统。
uname -m
x86_64
All the libs are of 32 bit.
所有的库都是32位的。
/usr/bin/ld lib/libssh2.so
lib/libssh2.so could not read symbols: File in wrong format
file lib/libssh2.so
lib/libssh2.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, stripped
While compiling I am getting error:
编译时我收到错误:
usr/bin/ld: cannot find -lssh2
collect2: ld returned 1 exit status
Command to compile:
编译命令:
g++ src/Testcase.o src/Test.o -L../testcase/lib -L/usr/lib -L/usr/lib \
-lcrypto -lz -lpthread -lssl -lcurl -lssh2 -o ./debug/testcase
1 个解决方案
#1
There are two errors.
有两个错误。
The first one says that libssh2.so
is a 32-bit shared library, but you link on a 64-bit platform. On a 64-bit platform it normally links to 64-bit objects by default. Add -m32
switch to your compile and link command lines to build and link in 32-bit mode.
第一个说libssh2.so是一个32位的共享库,但是你在64位平台上进行链接。在64位平台上,它通常默认链接到64位对象。添加-m32切换到编译和链接命令行以在32位模式下构建和链接。
The second one is that the linker cannot find -lssh2
. In this case you need to specify the directory where to look for -lssh2
, e.g. -L/usr/local/lib -lssh2
.
第二个是链接器找不到-lssh2。在这种情况下,您需要指定查找-lssh2的目录,例如-L / usr / local / lib -lssh2。
#1
There are two errors.
有两个错误。
The first one says that libssh2.so
is a 32-bit shared library, but you link on a 64-bit platform. On a 64-bit platform it normally links to 64-bit objects by default. Add -m32
switch to your compile and link command lines to build and link in 32-bit mode.
第一个说libssh2.so是一个32位的共享库,但是你在64位平台上进行链接。在64位平台上,它通常默认链接到64位对象。添加-m32切换到编译和链接命令行以在32位模式下构建和链接。
The second one is that the linker cannot find -lssh2
. In this case you need to specify the directory where to look for -lssh2
, e.g. -L/usr/local/lib -lssh2
.
第二个是链接器找不到-lssh2。在这种情况下,您需要指定查找-lssh2的目录,例如-L / usr / local / lib -lssh2。