|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Trouble linking through g++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.
Thanks,
Madhav Ancha.
_______________________________________________ Help-make mailing list Help-make@... http://lists.gnu.org/mailman/listinfo/help-make |
|
|
Trouble linking through g++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.
Thanks,
Madhav Ancha.
_______________________________________________ Help-make mailing list Help-make@... http://lists.gnu.org/mailman/listinfo/help-make |
|
|
Re: Trouble linking through g++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. _______________________________________________ Help-make mailing list Help-make@... http://lists.gnu.org/mailman/listinfo/help-make |
|
|
Re: Trouble linking through g++Thanks Greg. That helped.
-Madhav.
On Thu, Oct 15, 2009 at 9:33 AM, Greg Chicares <gchicares@...> wrote:
_______________________________________________ Help-make mailing list Help-make@... http://lists.gnu.org/mailman/listinfo/help-make |
|
|
Re: Trouble linking through g++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 > <gchicares@...> 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. _______________________________________________ Help-make mailing list Help-make@... http://lists.gnu.org/mailman/listinfo/help-make |
|
|
Re: Trouble linking through g++On 10/15/2009 8:03 AM, Madhav Ancha wrote: Hi, 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 _______________________________________________ Help-make mailing list Help-make@... http://lists.gnu.org/mailman/listinfo/help-make |
|
|
Re: Trouble linking through g++Thanks John,
Madhav. On Thu, Oct 15, 2009 at 11:44 AM, John Calcote <john.calcote@...> wrote:
_______________________________________________ Help-make mailing list Help-make@... http://lists.gnu.org/mailman/listinfo/help-make |
| Free embeddable forum powered by Nabble | Forum Help |