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

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/

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.

What causes a library not found error in gcc, when the library exists?

After a reformat/reinstall of Linux, I'm trying to build some code that used to work. I'm not sure how to debug this sort of error. While I'd like to know what's wrong with this code below, I'd like to also know how to track down the problem -- what are the clues to look for?
$ more test.c
void main() {}
$ gcc test.c
<works>
$ gcc test.c -lboost_system
/usr/bin/ld: cannot find -lboost_system
collect2: error: ld returned 1 exit status
$ gcc test.c -lboost_filesystem
/usr/bin/ld: cannot find -lboost_filesystem
collect2: error: ld returned 1 exit status
$ locate boost_filesystem
/usr/lib64/libboost_filesystem.so.1.58.0
$ locate boost_system
/usr/lib64/libboost_system.so.1.58.0
$ uname -a
Linux mycomputer 4.2.6-301.fc23.x86_64 #1 SMP Fri Nov 20 22:22:41 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ sudo dnf list installed | grep boost
boost-date-time.x86_64 1.58.0-9.fc23 #updates
boost-filesystem.x86_64 1.58.0-9.fc23 #updates
boost-iostreams.x86_64 1.58.0-9.fc23 #updates
boost-system.x86_64 1.58.0-9.fc23 #updates
boost-thread.x86_64 1.58.0-9.fc23 #updates
UPDATE
#Kenny suggested I look for the devel package. It wasn't installed. dnf install boost-devel and it got installed. Then, when I run gcc test.c -lboost_system, it works. However, I'm still at a loss. What mechanism/file/setting got changed to make this work? When I run locate boost_system, I still come up with the same. I realize that package installed some header files, but my test.c didn't mention boost in it.
In Debian and Debian-derived distros, such as Ubuntu, library packages are usually divided in the binary package and the development package.
The library binary package will usually have the shared library file, with its full, three-digit-version name (libfoo.so.1.2.3) and a symlink to it with the one and/or two-digit-version name (libfoo.so.1.2, libfoo.so.1) pointing to the first one. This one-or-two-digit-version file is what it is actually looked for when running a program (google for ELF SONAME for details).
The library development package will usually contain the header files (*.h) and a symlink without any version numbers to the shared object (libfoo.so). Optionally, there may be also a static library file (libfoo.a).
Now, when you compile a program and you add the -lfoo option, the linker will look for a file libfoo.so that is actually a symlink to libfoo.so.1.2.3 and it will use that file as a shared library.
And that's why this symlink is in the dev package and not the bin one: since the shared library has a SONAME with libfoo.so.1 or libfoo.so.1.2 the runtime program does not need the libfoo.so symlink. It's only used for building.
PS: to see the files in a package do not use locate. Use dpkg -L libboost-filesystem-dev.

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..

"cannot find -lreadline" error when compiling Lua

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

glui /usr/bin/ld: cannot find -lXmu

I have downloaded the latest GLUI source code and now I am trying to compile it. When I do so, I get the following error:
g++ -O0 -Wall -pedantic -I./ -I./include -I/usr/X11R6/include -o bin/example1 example/example1.cpp -L./lib -lglui -L/usr/X11R6/lib/libXdmcp.a -lglut -lGLU -lGL -lXmu -lXext -lX11 -lXi -lm
/usr/bin/ld: cannot find -lXmu
collect2: ld returned 1 exit status
When I did a locate libXmu, I get the following output:
> %:~/src/GLUI/src$ locate libXmu
> /usr/lib/libXmu.so.6
> /usr/lib/libXmu.so.6.2.0
> /usr/lib/libXmuu.so.1
> /usr/lib/libXmuu.so.1.0.0
Do I get the error because I don't have a /usr/lib/libXmu.so? If this is the case, how can I make one? (I am not experienced with linking at all).
Thanks!
Linux distributions usually package the libraries needed for running programs separately from the files needed to build programs.
Look for packages named *-devel or *-dev.
I don't know which one you need in particular for this, but you can use apt-cache search to look for it.
The answer was actually one of the first ones here originally but the owner deleted it, it seems. I was able to solve the problem by creating a symbolic link to the latest version of the library (i.e. /usr/lib/libXmu.so.6) and compile the code successfully.
I had the same problem, if creating a symbolic link doesnt help,
try the following:
Print your $PATH ("echo $PATH"),
and check if the library file you need is in one of those directories.
Use "export PATH=/newly/added/path:$PATH" to add new directory to check.
Ive been including libevent, added "-levent" in the gcc command, and ld used file /usr/lib/libevent.so, so it looks like the "lib" prefix and extension are being added automatically by ld.
Keep it up.

Resources