Compilation error for RISCV gcc when try to include -lcrypto - linux

I am running openssl benchmarks on Ubuntu Linux. Initially, there was some problem with the missing library. Later I fixed it by installing the library with the installation command sudo apt-get install libssl-dev. When I compiled using gcc command gcc sha256t.c -o sha -lcrypto, it generates binary but when compiled using RISCV gcc command riscv64-unknown-elf-gcc sha256.S -o sha.riscv -lcrypto, it throws the following link error.
/home/user_name/fpga-zynq/rocket-chip/riscv-tools/riscv/lib/gcc/riscv64-unknown-elf/6.1.0/../../../../riscv64-unknown-elf/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status.
How to link the -lcrypto in this case.

You need a libcrypto compiled for the riscv64 architecture.
What you installed with sudo apt-get install libssl-dev is a libcrypto compiled for your host architecture (likely x86_64), it cannot be used for cross-compiling.
If you can't find a pre-built libcrypto for riscv64, you might have to compile it yourself, with that same riscv64 cross-compiler you're using.
Automating this is what yocto or buildroot is all about.

Related

Compile python3 script with Cython | CentOs 6.x

I've previously compiled the script with cython on ubuntu and it works fine on all ubuntu os but it doesnt works on centos, it failes with this error: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory.
So I tried to compile the script on centos but when I try to compile the C source code generated by Cython with the following command gcc -Os -I /usr/include/python3.6m -o a.o script.c -lpython3.6m -lpthread -lm -lutil -ldl
I get this error script.c:4:20: error: Python.h: No such file or directory
script.c:6:6: error: #error Python headers needed to compile C extensions, please install development version of Python..
I've tried to install python3 dev libs but seems like they don't exist for CentOs 6, and search for someone who has the same problem but I haven't found anything usefull so far.
I think I can solve the issuse by installing python3-devel.
SOLUTION: https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-centos-7
for centos 6 install ius repo like this:
yum install https://repo.ius.io/ius-release-el6.rpm https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm -y (source: https://ius.io/setup)

Binaries are not executing after AFL installation in qemu mode

I have recently installed AFL and then its qemu mode, for which I required following packages.
'sudo apt-get install libtool automake bison libglib2.0-dev zlib1g-dev'
With these packages installed qemu installation worked fine. But after its installation whenever I tried to run binary with it, it generated AFL FORK SERVER HANDSHAKE FAILED error. I run my binary independently and it generated this error
cannot execute binary file: Exec format error.
I searched and found out this error is because of conflicting architectures which isn't in my case as I have build and run on same machine. Compiling with libtool also hasnot been a success libtool --mode=compile gcc -c one.c -o testlib.o.
I am also unable to execute any binary I create as default permissions are -rw-rw-r--, so I have to change their mods after creating them. This was not happening before above packages and installations. I even un-installed libtool but no success.
Any suggestions?
This has nothing to do with the libtool installation. I was making a silly mistake by using gcc -c test.c -o test.o which was not performing linking, see this. All I did is use command gcc test.c -o test.o and everything worked fine.

How to use g++-3.4 in ubuntu 15.04

I want to use g++3.4 in ubuntu 15.04, but I have trouble doing it for a week.
I followed the answer to install g++3.4.
https://askubuntu.com/questions/39628/old-version-of-gcc-for-new-ubuntu
And I chose g++-3.4 with the method provided on
https://askubuntu.com/questions/26498/choose-gcc-and-g-version
When I want to compile a cpp file, an error display:
/usr/bin/ld: cannot find -lgcc_s.
So I searched a lot of information about the problem, I find the following:
http://serverfault.com/questions/266138/cannot-find-lgcc-s-from-gcc-3-4-on-ubuntu-11-04
Because I don't have i486-linux-gnu directory, I typed
sudo ln /lib/i386-linux-gnu/libgcc_s.so.1 /usr/lib/gcc/x86_64-linux-gnu/3.4.6/libgcc_s.so
But the terminal displayed the error:
ln: failed to create hard link ‘/usr/lib/gcc/x86_64-linux-gnu/3.4.6/libgcc_s.so’: File exists
then I type the command
sudo cp /lib/i386-linux-gnu/libgcc_s.so.1 /lib/libgcc_s.so.1
It seemed to work. But when I compiled again, the terminal showed that
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/3.4.6/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/3.4.6/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
Afterward I thought that it was because I didn't have 32-bit support. But I couldn't download ia32-libs package. It seems that the package don't exist on latest ubuntu.
Now I have installed gcc-multilib,lib32gcc1 and libgl1-mesa-dri:i386, and I also have tried the command:
sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install ia32-libs
I still don't have 32bit support. What should I do?
Not sure you need a 32bits compiler ? Anyway, none of the older compilers, gcc versions 4.3 and lower can be used with Ubuntu 11.10 ... 15.10 .
The information in "askubuntu" etc. is wrong.
The usable version of gcc/g++-3.4.6 is { compat-gcc34-3.4.6-ubuntu1204-1_amd64.deb, compat-gcc-34-c++_3.4.6-20_amd64.deb }
Links for the "amd64 packages" :
compat-gcc34 https://drive.google.com/file/d/0B7S255p3kFXNRTkzQnRSNXZ6UVU/view?usp=sharing
compat-g++34 https://drive.google.com/file/d/0B7S255p3kFXNV3J3bnVoWGNWdG8/view?usp=sharing
.... provides /usr/bin/{ gcc34, g++34 }.
compat-gcc34

trouble linking lapack

i am trying to link lapack and a simple
locate lapack
returns
/usr/lib64/liblapack.so.3
/usr/lib64/liblapack.so.3.2.1
so in am trying to link it with
gfortran -o linreg driver.f90 LFsubroutines.f90 -L/usr/lib64 -llapack -fimplicit-none
but i get the following error:
/usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../x86_64-suse-linux/bin/ld: cannot find -llapack
what is the problem here?
You don't have the liblapack.so or liblapack.a file there (maybe you didn't install dev(el) package). You may try specifying the complete path instead
gfortran -o linreg driver.f90 LFsubroutines.f90 /usr/lib64/liblapack.so.3 -fimplicit-none
Try installing the following packages if you don't have the devel packages installed already on your system.
sudo yum install libgfortran libf2c blas lapack
Give that a shot...

"/usr/bin/ld: cannot find -lz"

I am trying to compile Android source code under Ubuntu 10.04. I get an error saying,
/usr/bin/ld: cannot find -lz
Can you please tell me how can I fix it? What does cannot find -lz mean? Here's the full error message:
external/qemu/Makefile.android:1101: warning: overriding commands for target `external/qemu/android/avd/hw-config-defs.h'
external/qemu/Makefile.android:933: warning: ignoring old commands for target `external/qemu/android/avd/hw-config-defs.h'
host SharedLib: libneo_cgi (out/host/linux-x86/obj/lib/libneo_cgi.so)
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../libz.so when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../libz.a when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/libz.so when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/libz.a when searching for -lz
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libneo_cgi.so] Error 1
And my GCC version output:
scheung#scheung-virtual-box:/media/EXTDIV/mydroid$ gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I already have the zlib1g-dev library installed:
$ sudo apt-get install zlib1g-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
zlib1g-dev is already the newest version.
(I get that from this link.)
I had the exact same error, and like you, installing zlib1g-dev did not fix it. Installing lib32z1-dev got me past it. I have a 64 bit system and it seems like it wanted the 32 bit library.
For x64 install zlib1g-dev.
sudo apt-get install zlib1g-dev
I don't need all the x86 libs ;)
sudo apt-get install libz-dev in ubuntu.
I just encountered this problem and contrary to the accepted solution of "your make files are broken" and "host includes should never be included in a cross compile"
The android build includes many host executables used by the SDK to build an android app.
In my case the make stopped while building zipalign, which is used to optimize an apk before installing on an android device.
Installing lib32z1-dev solved my problem, under Ubuntu you can install it with the following command:
sudo apt-get install lib32z1-dev
I had the exact same error, Installing zlib-devel solved my problem,
Type the command and install zlib package.
On linux:
sudo apt-get install zlib*
On Centos:
sudo yum install zlib*
Another possible cause: You've passed --static to the linker, but you only have a dynamic version of libz (libz.so), but not a version that can be statically linked (libz.a).
Try one of those three solution. It must work :) :
sudo apt-get install zlib1g-dev
sudo apt-get install libz-dev
sudo apt-get install lib32z1-dev
In fact what is missing is not the lz command, but the development files for the zlib library.So you should install zlib1g-devlib for ex to get it.
For rhel7 like systems the package is zlib-devel
It means you asked it to include the library 'libz.a' or 'libz.so' containing a compression package, and although the compiler found some files, none of them was suitable for the build you are using.
You either need to change your build parameters or you need to get the correct library installed or you need to specify where the correct library is on the link command line with a -L/where/it/is/lib type option.
This will show you clues about why the linker doesn't want the installed library:
LD_DEBUG=all make ...
I had the same problem in a different context: my system /lib/libz.so.1 had unsatisfied dependencies on libc because I was trying to relink on a different version of the OS.
for opensuse 12.3 (Dartmouth) (i586)
sudo zypper install zlib-devel zlib-devel-static
Others have mentioned that lib32z-dev solves the problem, but in general the required packages can be found here:
http://source.android.com/source/initializing.html
See "Installing required packages"

Resources