help-make
[Top][All Lists]
Advanced

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

Re: Using "-l" libraries as targets


From: Paul Smith
Subject: Re: Using "-l" libraries as targets
Date: Mon, 01 Jun 2015 09:08:35 -0400

On Mon, 2015-06-01 at 21:21 +0900, Luke Allardyce wrote:
>  That results in "make: *** No rule to make target '-lfoo', needed by
> 'main.exe'.  Stop.", unless of course libfoo.a is already installed.

Oh right.  I forgot: the "-lxxx" form is only valid for system libraries
or other pre-existing libraries that make doesn't need to build.

You cannot use it for libraries make has to build, because make doesn't
know what name to use for them.  Remember make starts from the final
target to be built and works backwards, looking at prerequisites.  So
when make sees a prerequisite like "-lfoo", it then tries to look up the
name existing on the filesystem using the algorithms described in the
manual.  Since the file doesn't exist yet make doesn't know which one it
should build.

An option here would be for make to treat this like a pattern and try to
find a rule to build each of the possible expansions of "-lfoo", but it
doesn't do that.  I'm not sure if that's something that would be useful
to add, or not.  Personally I think it's better to be explicit about
prerequisites you want make to build, and just not use the "-lfoo"
trick.




reply via email to

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