Solved

Makefile question.  "No rule to make target..."

Posted on 2006-07-13
4
4,021 Views
Last Modified: 2011-04-14
If I have a makefile rule like:

myprog.o : myprog.cpp
    g++ -g -Wall -c myprog.cpp

Why does make say:
"make:  *** No rule to make target `myprog.cpp', needed by `myprog.o'.  Stop."

How do you set up a rule to make a cpp file?
0
Comment
Question by:lwinkenb
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
smidgie82 earned 150 total points
ID: 17100960
Hi lwinkenb,

Unless you're using a code generator such as lex or yacc (or flex or bison), of course, you shouldn't have to have a rule to make a cpp file.  make should automatically discover that the dependency as specified references a file, not a rule.  The short answer is that myprog.cpp most likely isn't visible in make's search path from wherever you're calling it.  Or at least that's how I just duplicated the error you posted.


Cheers!
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 17101045
well I do have a directory structure like:

Makefile
Sources (directory)
Include (directory)

How do I tell the Makefile that the source files are in the Sources directory.
0
 
LVL 8

Assisted Solution

by:manish_regmi
manish_regmi earned 100 total points
ID: 17101066
all:
    make -C Sources

this will get you inside the Sources directory and the makefile in that directory will run


regards
Manish Regmi
0
 
LVL 8

Expert Comment

by:manish_regmi
ID: 17101094
then in the sources directory you can do

INCL = -I. -I../ -I../Include
OPTIONS = -Wall -O2

all:
.c.o:
      $(CC) -c $(OPTIONS) $(INCL) $< -o $@


regards
Manish Regmi
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question