help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble linking through g++


From: Paul Smith
Subject: Re: Trouble linking through g++
Date: Thu, 15 Oct 2009 10:45:57 -0400

On Thu, 2009-10-15 at 09:38 -0500, Madhav Ancha wrote:
> Thanks Greg. That helped.

If possible, please don't top-post to technical lists.  Thanks.

> On Thu, Oct 15, 2009 at 9:33 AM, Greg Chicares
> <address@hidden> wrote:
>         On 2009-10-15 14:03Z, Madhav Ancha wrote:
>         >
>         >      LINK_FLAGS= -g -pg -fprofile-arcs -ftest-coverage -fPIC
>         -Lrelease1
>         >       testApp: file.o -lSharedLib
>         >       $(CXX) $(LINK_FLAGS) -o $@ $^
>         >
>         > Error:
>         >      make: *** No rule to make target `-lSharedLib', needed
>         by `testApp'.
>         >  Stop.
>         
>         
>         '-lSharedLib' is a linker flag, but you've given it as a
>         prerequisite.
>         Add it to your 'LINK_FLAGS' instead.
>         
>         If you want the shared library to be a prerequisite, specify
>         its actual
>         filename (e.g., 'libSharedLib.so'), and make sure your
>         makefile contains
>         a rule to build it.

Note that GNU make supports the special syntax of "-l<lib>" as a
prerequisite.  This asks GNU make to look up the library by doing a
textual substitution such as "lib<lib>.a" and "lib<lib>.so" and, if
found, it will use it as a prerequisite (as well as appearing in $^).

If not found, it treats the prerequisite as a normal file name; that's
what you're seeing here.

There are various things you need to do; for example make can't parse
your linker line to see the -Lrelease1 flag, so you have to tell make
where to look for the library (using vpath).  Also, if your library is
not using one of the standard library extensions you need to configure
GNU make to look for it.

See the gnu make manual for full details.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]