help-make
[Top][All Lists]
Advanced

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

Re: Trouble linking through g++


From: Madhav Ancha
Subject: Re: Trouble linking through g++
Date: Thu, 15 Oct 2009 12:14:03 -0500

Thanks John,
Madhav.


On Thu, Oct 15, 2009 at 11:44 AM, John Calcote <address@hidden> wrote:
Hi Madhav,

On 10/15/2009 8:03 AM, Madhav Ancha wrote:
Hi,

   When I run the linker through the command line like this, it works. 
      g++ -g -pg -fprofile-arcs -ftest-coverage -Lrelease1 -o testApp file.o -lSharedLib
   
   But when i run from a make file with the follow equivalent commands, it does not. It gives the error reproduced below. can you help debug the cause. 

     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.

A makefile contains rules and command (and other things). Rules are lists of targets, followed by separator (colon, double-colon, etc), followed by lists of dependencies. Commands are lines prefixed with a TAB character. In your rule, you have a linker option (-lSharedLib) in your dependency list. The target list and the dependency list must only contain file names, or macros that resolve to file names, or patterns (containing '%' or '*' characters) that can match file names. You can't put anything else into either the target or dependency list. What you probably wanted to write was this (untested):

LINK_FLAGS= -g -pg -fprofile-arcs -ftest-coverage -fPIC -Lrelease1
testApp: file.o
$(CXX) $(LINK_FLAGS) -o $@ file.o -lSharedLib

Note that I changed $^ to file.o in the command line because $^ is not portable between various flavors of make.

John


reply via email to

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