"cannot find -lreadline" error when compiling Lua - linux

This should be a pretty straightforward issue -- I'm trying to compile Lua (or rather lua-vec, which is a minor variant) on a CentOS Linux install, and I get the following error:
[jt#flyboy src]#make linux
make all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
make[1]: Entering directory `/jt/flyboy/fly/lua/lua-vec/src'
gcc -o lua lua.o liblua.a -lm -Wl,-E -ldl -lreadline -lhistory -lncurses
/usr/bin/ld: cannot find -lreadline
collect2: ld returned 1 exit status
make[1]: *** [lua] Error 1
That would suggest the readline lib is not installed. But...
[jt#flyboy src]#ls /usr/lib/libreadline*
/usr/lib/libreadline.so.5 /usr/lib/libreadline.so.5.1
Interestingly, if I rearrange the order of readline/history/ncurses, whichever is first triggers the same error, so I suspect that this is some sort of a folder-specification problem, not a missing library problem.
Any ideas?
yum install readline-devel.x86_64 readline-devel.i386 ncurses-devel.i386 ncurses-devel.x86_64
seems to have done the trick! The odd thing is I have compiled this before without these libs... but enough time pondering life's mysteries...

libreadline is not enough, it will give you libraries related to readline. You need libreadline-dev for compiling package which depends upon readline like in above case.
In Red Hat like distros, name of package is readline-devel
Following command will do the trick in such environment:
$ yum install -y readline-devel

If somebody has this issue in ubuntu/debian:
sudo apt-get install libreadline-dev

Related

Micronucleus does not update

I'm trying to upgrade my micronuclues to upload my code to digispark,but when I try to upgrade that happens:
Building command line tool: micronucleus...
gcc -Ilibrary -O -g -D LINUX -o micronucleus micronucleus.c micronucleus_lib.o littleWire_util.o -static -L/usr/lib/x86_64-linux-gnu -lusb
/usr/bin/ld: cannot find -lusb
collect2: error: ld returned 1 exit status
make: *** [Makefile:61: micronucleus] Error 1
I'm a little confused as to how you've gotten it compiling but not linking because, at least on Debian based distributions, the header file that would be needed during compiling is provided by the same package that provides the libusb.a that it is failing to link against.
If you are on a Debian based distro, try (re)installing libusb-dev:
sudo apt install libusb-dev
This is what I've built it against locally.
If you have a libusb.a and it's not in /usr/lib/x86_64-linux-gnu, then you'd need a different directory supplied to -L.

Which package we need to install to remove -lgcc_s error?

I am getting this error when i compile my test file in linux centOS7.
/usr/bin/ld : cannot find -lgcc_s
collect2: error: ld return 1 exit status
It means, it's not finding an existing library gcc_s.
One reason for this, this is because although libgcc is present, it may not be not in the paths known to ldconfig.
try this by doing
sudo /sbin/ldconfig -p | grep libgcc
if the output show that the is link to libgcc corresponds to paths that you have listed above?
A workaround for you may be to add the link to the relevant library to your compile command, for example, it will do the job.
g++ yourprogram.cpp -L /usr/lib/gcc/x86_64-linux-gnu/4.6/

glib-networking cannot find gio/gio.h

I am trying to build glib-networking-2.40.1. I am having trouble with the make step.
Configure step
~/gstreamer/plugins/recommended/good/glib-networking-2.40.1 $ sudo ./configure --disable-glibtest --host=arm-linux-gnueabi --prefix=$DISCIMAGE/usr/local/ --includedir=$DISCIMAGE/usr/include/glib-2.0 --libdir=$DISCIMAGE/usr/lib/arm-linux-gnueabi --libdir=$DISCIMAGE/usr/lib --exec-prefix=$DISCIMAGE/usr/local/ --includedir=$DISCIMAGE/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/include --includedir=$DISCIMAGE/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/glib --with-ca-certificates=/etc/ssl/ca-bundle.crt --includedir=$DISCIMAGE/home/ubuntu/gstreamer/plugins/recommended/good/gnutls-3.3.7/ --includedir=$DISCIMAGE/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/ --with-gnutls=/home/ubuntu/gstreamer/plugins/recommended/good/gnutls-3.3.7/ --libdir=/usr/lib/arm-linux-gnueabihf/ --libdir=/usr/lib --libdir=/usr/lib/arm-linux-gnueabi --libdir=/usr/lib/arm-linux-gnueabihf/ --libdir=/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/gio/.libs/
then I try
sudo make
and I get the error
CC gnutls-module.lo
gnutls-module.c:22:21: fatal error: gio/gio.h: No such file or directory
gio.h is located at
/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/gio/
which is included in my configure step
also I have libgio-2.0.so located at
/usr/lib/libgio-2.0.so
and
/usr/lib/arm-linux-gnueabihf/gio/libgio-2.0.so.0
and
/usr/lib/libgio-2.0.so.0
all of which are included in configure
pkg-config gives
sudo pkg-config --libs --cflags gio-2.0
-pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lgio-2.0 -lgobject-2.0 -lglib-2.0
Any help would be greatly appreciated
The --includedir and --libdir arguments to configure are supposed to tell your package where to install its own headers and libraries, not where to find other headers and libraries. You should not normally need to use those arguments.
Making that mistake when you compiled GLib is presumably why your gio.h is located at /home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/gio/ instead of at /usr/include or /usr/local/include.
Instead, the output of pkg-config should tell your program where to find headers and libraries. If you've installed your package properly, then pkg-config's output should be correct. The idea is that instead of you researching where all the libraries live and passing those paths to configure, each library installs a pkg-config file that has that information, so if you know where the pkg-config files are, then you don't need to know anything else.
So probably you should uninstall, recompile, and reinstall all the packages you've been compiling, reconfiguring them without the --include and --libdir arguments.

configure test with static lib

I am trying to cross compile libpng for RaspberryPi on Ubuntu 14.04 (x_64) with zlib
but configure fails with
configure:11400: arm-linux-gnueabihf-gcc -o conftest -g -O2 -I/home/user/RPI_DEV/lib/include conftest.c -lz -lm >&5
/home/user/RPI_DEV/xtools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
configure:11400: $? = 1
configure: failed program was:
....
Because I am using toolchain for arm, arm-ld cant find zlib.
Is there any option for configure not to compile with shared lib but to try with static lib (eg. -static -lz).
Command is
./configure --enable-static=true --enable-shared=false --with-zlib-include="/home/user/RPI_DEV/lib/include" --with-zlib-lib="/home/user/RPI_DEV/lib/lib" LDFLGS="-L/home/user/RPI_DEV/lib/lib" CPPFLAGS="-I/home/user/RPI_DEV/lib/include" -enable-static --host=arm-linux-gnueabihf --prefix=/home/user/RPI_DEV/lib --exec-prefix=/home/user/RPI_DEV/lib
You need to cross build and install zlib into your toolchain before trying to use it in another project.
What you are doing might work but only if you spell LDFLAGS correctly:
LDFLGS="-L/home/user/RPI_DEV/lib/lib"
Note the missing 'A'. I don't know why your second attempt worked, given you had the same misspelling; possibly you had a correct LDFLAGS in your environment?
Anyway there should be a Ubuntu cross-development guide somewhere that explains how to do this. It's slightly off topic but for Gentoo you use 'crossdev' to install the toolchain then a crossdev specific version of the normal package installation mechanism ([host]-emerge) to install zlib into the toolchain.
Also, the arguments --with-zlib-include and --with-zlib-lib are not supported by any current version of libpng I can find. If you are cross-compiling libpng for an RPi (or, indeed, any ARM system) you should be using the latest version of 1.6 that you can find.
Unless someone solves this the RIGHT way, this is hack I've done.
Open configure.ac file
Find and comment out line
AC_CHECK_LIB(z, zlibVersion, , AC_ERROR([zlib not installed]))
Configure will pass wihout check for zlib and then add zlib by hand
LDFLGS="-L/home/user/RPI_DEV/lib/lib -L/home/user/RPI_DEV/lib/lib/libz.a"
Run autoconf
Run ./configure ...

Cannot find -ly error

I am trying to run a lexx and yacc program and I got the following error:
/usr/bin/ld: cannot find -ly
collect2: error: ld returned 1 exit status
Plz tell me which libraries am I supposed to add?
Could you find liby.a in /lib dir? If you don't have the file, you can use apt-file liby.a to find the package which includes it. In my case, apt install libbison-dev works.
I would guess the problem is that you're using a version of yacc other than the old AT&T yacc which doesn't come with liby (the -ly you have). So you need to remove the -ly option from your command line, and provide your own implementations of main and yyerror.
What version of yacc and lex have the "-ly" parametr?
I used this command in my university:
gcc gram.c gram.h sem.c -ly -ll
or
cc gram.c gram.h sem.c -ly -ll
And works! But on my home komputer doesn't work..

Resources