tags:

views:

95

answers:

1

I get the following error when I try to compile my app:

*** No rule to make target `/mypath/lib/libm.a', needed by `/myPath/bin/appName'

Why is the linker looking for libm.a according to an absolute path?

+3  A: 

I start thinking of swithcing programming to psychic career...

Why is the linker looking for libm.a according to an absolute path?

Because you told him to do so. Most likely you've typed

# There were some rules that build your own .a libs
myLib.a: ...
   ...

# Handy rule to direct your libs into lib/ folder!
vpath %.a /mypath/lib

appName: appName.o libm.a
   g++ $^ -o $@

Whoops! You need "system" libm.a (that's a math library, a part of glibc), but make thinks that you need your own static library. It then adds the proper prefix and doesn't find any rule to remake libm.a.

A solution could be moving libm.a out of prerequisites. That's the purpose of configure script or a special make sanity target to check the existence of system libraries.

EXT_LIBS=libm.a

appName: appName.o
   g++ $^ $(EXT_LIBS) -o $@
Pavel Shved
The error message is from make, not from the linker, so this answer is most likely correct.
Employed Russian