?
Solved

Makefile

Posted on 2004-09-27
7
Medium Priority
?
1,199 Views
Last Modified: 2008-01-09
Hi,

I'm trying to reuse a makefile, unfortuneatly i'm not that familar with their structure and am utter perplexed. Hopefully someone will be able to lend a hand. The error message I'm getting is:
"No rule to make target "test.o" needed by test.x. STOP"

******makefile***************
TARGET_ARCH = cygwin
CC = g++
OPT    = -O3
DEBUG  =    
CFLAGS = $(DEBUG) $(OPT) -fexceptions
MODULE = test
SRCS = test.cpp
OBJS = $(SRCS:.cpp=.o)
include ./Makefile.defs

****** makefile.defs***********
SYSTEMC = /cgydrive/c/SystemC/systemc-2.0.1
INCDIR = -I. -I.. -I$(SYSTEMC)/include
LIBDIR = -L. -L.. -L$(SYSTEMC)/lib-$(TARGET_ARCH)
LIBS   =  -lsystemc -lm $(EXTRA_LIBS)
EXE    = $(MODULE).x
.SUFFIXES: .cc .cpp .o .x
$(EXE): $(OBJS) $(SYSTEMC)/lib-$(TARGET_ARCH)/libsystemc.a
      $(CC) $(CFLAGS) $(INCDIR) $(LIBDIR) -o $@ $(OBJS) $(LIBS) 2>&1 | c++filt
.cpp.o:
      $(CC) $(CFLAGS) $(INCDIR) -c $<
.cc.o:
      $(CC) $(CFLAGS) $(INCDIR) -c $<
clean::
      rm -f $(OBJS) *~ $(EXE) core
ultraclean: clean
      rm -f Makefile.deps
Makefile.deps:
#      $(CC) $(CFLAGS) $(INCDIR) -M $(SRCS) >> Makefile.deps
#include Makefile.deps
0
Comment
Question by:trican
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 12165063
Try

OBJS = test.o
0
 
LVL 12

Expert Comment

by:stefan73
ID: 12167093
Hi trican,
You should check if you either have test.cc or test.cpp.

Cheers!

Stefan
0
 
LVL 1

Author Comment

by:trican
ID: 12167199
Stefan - the file exists - test.h & test.cpp

jkr - when i do that, i get a message about the library I've included - no rule to make target "/cgydrive/c .....", but this has already been compiled

confused :-(

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Accepted Solution

by:
stefan73 earned 1200 total points
ID: 12167344
trican,
> message about the library

You have named the library as a dependency in the
$(EXE): $(OBJS) $(SYSTEMC)/lib-$(TARGET_ARCH)/libsystemc.a

line, but you don't have a rule how to re-create the library.

Ouch:
SYSTEMC = /cgydrive/c/SystemC/systemc-2.0.1

Correct the typo and run again.
0
 
LVL 1

Author Comment

by:trican
ID: 12171036
ouch indeed....
the library (systemc) contains its own makefiles etcso it seems to be getting more complicated by the second.
0
 
LVL 1

Author Comment

by:trican
ID: 12189977
ok, things are getting slightly better,

here now is the error message i'm getting:
g++ -O3 -Wall -I. -I.. -I/home/*****/systemc-2.0.1/include -c -o src/Test.o src/Test.cpp
g++ -O3 -Wall -I. -I.. -I/home/****/systemc-2.0.1/include -L. -L.. -L/home/*****/systemc-2.0.1/lib-linux -o test.exe src/Test.o   -lsystemc -lm 2>&1 | c++filt
/home/******/systemc-2.0.1/lib-linux/libsystemc.a(sc_main.o): In function `main':
sc_main.o(.text+0x1d): undefined reference to `sc_main'
collect2: ld returned 1 exit status




And this is the make file I'm using now.......


#Setup libraries etc
TARGET_ARCH = linux
SYSTEMC = /home/**********/systemc-2.0.1
INCDIR = -I. -I.. -I$(SYSTEMC)/include
LIBDIR = -L. -L.. -L$(SYSTEMC)/lib-$(TARGET_ARCH)
LIBS   =  -lsystemc -lm

#BME_1xPE makefile
CC     = g++
OPT    = -O3
DEBUG  = -g
OTHER  = -Wall
CFLAGS = $(OPT) $(OTHER)
#CFLAGS = $(DEBUG) $(OTHER) debug version
MODULE = test
EXE    = $(MODULE).exe

SRCS:=  src/Test.cpp
OBJS = $(SRCS:%.cpp=%.o)
#OBJS = $(SRCS:.cpp=.o) - when i use this it doesn't create the .o file

$(EXE) : $(OBJS) $(SYSTEMC)/lib-$(TARGET_ARCH)/libsystemc.a  
      $(CC) $(CFLAGS) $(INCDIR) $(LIBDIR) -o $@ $(OBJS) $(LIBS) 2>&1 | c++filt

.cpp.o:
      $(CC) $(CFLAGS) $(INCDIR) -c $<

#%.o : %.cpp
#      $(CC) $(CFLAGS) $(INCDIR) -c -o $@ $<  

# cleaning everything that can be automatically recreated with "make".
clean:
      /bin/rm -f $(EXE) $(OBJS)

#dependancies
Test.o     : include/test.h
0
 
LVL 1

Author Comment

by:trican
ID: 12285770
ok figured it out myself - neverthe less the pointers were helpful - so I'll still award the points to  stefan73

incidentlyHow do you force the object files to be placed in a directory other than where the source file is located (just for tidyness)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

719 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