Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot find -lc and -lm in g++ linux

Tags:

include

gcc

g++

I am using Ubuntu and gcc and g++ were working fine but today it showed:

cannot find -lm
cannot find -lc

I searched and found it has something to do with /usr/bin/ld. Which is a symlink (I hope) to lbd.bdf. I pasted that file in the directory from Ubuntu of some friends PC. It didn't work.

I found that -lc means include static library libc.a.
similarly for -lm

I found them in my i386-linux-folders (name was something different).

I tried code blocks but same errors.

like image 636
Ashish Negi Avatar asked Sep 02 '11 13:09

Ashish Negi


2 Answers

The compiler cannot find static glibc, you might have installed only the shared libraries, try:

yum install glibc-static

like image 139
user1772382 Avatar answered Oct 28 '22 23:10

user1772382


make sure that your libpath (in g++) points to the directory(ies) that libm.a and libc.a are located in (use the -L option)

like image 6
KevinDTimm Avatar answered Oct 29 '22 00:10

KevinDTimm