473,322 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Makefile question

Hi NG,

I have the following MakeFile:

# Compiler
#---------------------------------------
CC = g++

APP = snake-client

# Compilerflags
#---------------------------------------
#CFLAGS += -O2

# Libraries
#---------------------------------------
LIB = -lncurses

# Sourcedateien
#---------------------------------------
SRC = snake-client.cpp CCursesWrapper.cpp

# Objektdateien
#---------------------------------------
OBJ = $(SRC:.cpp=.o)

$(APP): $(OBJ)
$(CC) $(OBJ) -o $(APP) $(LIB)

clean:
rm *.o

My problem is, I have a CCursesWrapper.h. I want to add this file to the
MakeFile, so that it will be included and newly compiled if I change the
CCursesWrapper.h. How can I do this?

Thank you

Matthias

Jul 22 '05 #1
3 1692
Matthias Pieroth wrote:
Hi NG,

Hi NG,

this is off-topic for comp.lang.c++. Try posting to comp.programming.
I have the following MakeFile: ....
My problem is, I have a CCursesWrapper.h. I want to add this file to the
MakeFile, so that it will be included and newly compiled if I change the
CCursesWrapper.h. How can I do this?

you'll need to add the rule

$(OBJ) : CCursesWrapper.h
# no commands...
However - if you want all this to happen automagically, use MakeXS.

(shameless plug)

http://www.makexs.com
Jul 22 '05 #2
Matthias Pieroth wrote:
My problem is, I have a CCursesWrapper.h. I want to add this file to the
MakeFile, so that it will be included and newly compiled if I change the
CCursesWrapper.h. How can I do this?


I think you want to recompile CCursesWarpper.o whenever CCursesWarpper.cpp
or CCursesWrapper.h is changed. So, you simply have to add a rule for
CCursesWrapper.o like

CCursesWrapper.o: CCursesWrapper.cpp CCursesWrapper.h
$(CC) -c -o $@ $< $(LIB)

if CCursesWrapper.h is located in the current directory (otherwise you have
to add -I <includedir> to the compiler options, where <includedir> stands
for the directory of CCursesWrapper.h).

HTH
Emanuel
Jul 22 '05 #3
Matthias Pieroth wrote:
Hi NG,

I have the following MakeFile:

# Compiler
#---------------------------------------
CC = g++

APP = snake-client

# Compilerflags
#---------------------------------------
#CFLAGS += -O2

# Libraries
#---------------------------------------
LIB = -lncurses

# Sourcedateien
#---------------------------------------
SRC = snake-client.cpp CCursesWrapper.cpp

# Objektdateien
#---------------------------------------
OBJ = $(SRC:.cpp=.o)

$(APP): $(OBJ)
$(CC) $(OBJ) -o $(APP) $(LIB)

clean:
rm *.o

My problem is, I have a CCursesWrapper.h. I want to add this file to the
MakeFile, so that it will be included and newly compiled if I change the
CCursesWrapper.h. How can I do this?

Thank you

Matthias


You can automate this process somewhat...

Do a man on mkdepends. Read carefully. It writes rules, but it changes
your Makefile while doing it. It is nice because it will run a
preprocessor on your source files and determine all the header files it
requires. It then proceeds to create rules and append them to your Makefile
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John Abel | last post by:
Hi, I've a small script, which listens to a port on a remote machine. I'm trying to implement makefile. However, the code on Win32 Py 2.2.2 def _Connect( self ): sockConn = socket.socket(...
4
by: Efrat Regev | last post by:
Hello, I'd like to ask a question concerning a python script in a makefile. Suppose I have a C++ project (sorry for raising this in a Python newsgroup), with some makefile for it. Before...
3
by: Faith | last post by:
any good tips on reading makefiles that were written using C++ ASAP please
4
by: newbiecpp | last post by:
I am very sorry to post this one because I know it is out of topic but I cannot find the proper news group. I understand that most senior C++ programmers know makefile very well. My question is...
1
by: Carson | last post by:
Hi, I have a problem with Makefile. I have a piece of c code, which is stored in my unix account. I wrote a Makefile for that particular compilation (using gcc), and it works fine. But...
4
by: srikar | last post by:
Hi can any one explain me the reason. For any Makefile there will be assosiated rules file, may be in same directory or in other directory. What is the need for this rules file. Is it that...
4
by: Jess | last post by:
Hello, I am now trying to use makefile to compile C++ programs. My makefile looks like: f1.o : f1.cpp h1.h h2.h g++ -c f1.cpp f2.o : f2.cpp h2.h h3.h g++ -c f2.cpp
9
by: raju2000myin | last post by:
i wrote one makefile but it shows multiple definition error how can i resolve that problem it is urgent to me please help to me............. ramesh............
7
by: HT-Lab | last post by:
Hi All, Not strictly a C++ question but I am sure this is a common compile issue :-) I have a generic makefile (see below) that I would like update such that if I make some changes to a header...
8
by: xz | last post by:
I am a rookie of C++ and got so confused with the Makefile these days. Could anyone be so kind and give a little sample Makefile for the following particular example? Let's say I have the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.