Solved

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

Posted on 2006-07-13
4
4,012 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now