LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-09-2005, 02:22 PM   #1
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 438

Rep: Reputation: 30
Adding more targets to Make


I've got a Makefile that searches the directory for a main.C file and compiles it into an executable.

I also have two new files that I want to be included in the compilation called flow_edge.C and flow_node.C. Can someone tell me how to edit the Makefile to include these files to be compiled with the main.C?

Here is the target section of the current Makefile:
Code:
#---------------------------------------------------------------------#
#                    target entries
#---------------------------------------------------------------------#

all:  main$(EXE_EXT)

main$(EXE_EXT): main$(OBJ_EXT)
	$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)main main$(OBJ_EXT) $(LDFLAGS) -lm

clean: \
	main.clean \
Thanks for any help.
 
Old 02-09-2005, 03:25 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
If I think correctly, this should work
Code:
main$(EXE_EXT): main$(OBJ_EXT) flow_edge($OBJ_EXT) flow_node($OBJ_EXT)
 
Old 02-09-2005, 04:11 PM   #3
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 438

Original Poster
Rep: Reputation: 30
Thanks for your reply, but that didn't seem to work. I'll tell you exactly what I'm trying to do, in case I might have left something out. I have a makefile that when make is called compiles a file main.C into an executable. I've created 2 new classes called flow_node.C and flow_edge.C both files also have header files. I want to be able to create flow_node and flow_edge objects in the main.C, so I'm going to need those source files when I call make. So I'm trying to figure out what I have to do to the makefile to include these sources so that main.C will compile into an executable.

Maybe I didn't edit the makefile correctly. Here is what I did:
Code:
#---------------------------------------------------------------------#
#                    target entries
#---------------------------------------------------------------------#

all:  main$(EXE_EXT)

main$(EXE_EXT): main$(OBJ_EXT) flow_edge($OBJ_EXT) flow_node($OBJ_EXT)
	$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)main main$(OBJ_EXT) $(LDFLAGS) -lm

clean: \
	main.clean \
Did I do something wrong?
Here is entire original makefile for reference:
Code:
# Created by the script create_makefile
# This is the makefile for compiling a CGAL application.

#---------------------------------------------------------------------#
#                    include platform specific settings
#---------------------------------------------------------------------#
# Choose the right include file from the <cgalroot>/make directory.

CGAL_MAKEFILE = /export/home/oulevon/CGAL-2.3/make/makefile_sparc_SunOS-5.7_g++-2.95.3_LEDA

include $(CGAL_MAKEFILE)

#---------------------------------------------------------------------#
#                    compiler flags
#---------------------------------------------------------------------#

CXXFLAGS = $(CGAL_CXXFLAGS) $(LONG_NAME_PROBLEM_CXXFLAGS) \
	$(DEBUG_OPT)

#---------------------------------------------------------------------#
#                    linker flags
#---------------------------------------------------------------------#

LIBPATH = \
	$(CGAL_LIBPATH)

LDFLAGS = \
	$(LONG_NAME_PROBLEM_LDFLAGS) \
	$(CGAL_LDFLAGS)

#---------------------------------------------------------------------#
#                    target entries
#---------------------------------------------------------------------#

all:  main$(EXE_EXT)

main$(EXE_EXT): main$(OBJ_EXT) 
	$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)main main$(OBJ_EXT) $(LDFLAGS) -lm

clean: \
	main.clean \

#---------------------------------------------------------------------#
#                    suffix rules
#---------------------------------------------------------------------#

.C$(OBJ_EXT):
	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $<
Thanks for any help.
 
Old 02-09-2005, 04:19 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
It looks that I misses one thing. Try this version:
Code:
main$(EXE_EXT): main$(OBJ_EXT) flow_edge($OBJ_EXT) flow_node($OBJ_EXT)
	$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)main main$(OBJ_EXT) flow_edge($OBJ_EXT) flow_node($OBJ_EXT) $(LDFLAGS) -lm
If it fail, please post errors you get.
 
Old 02-09-2005, 04:46 PM   #5
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 438

Original Poster
Rep: Reputation: 30
Thanks again for your help. I think that did the trick. I'm still getting some errors but they seem to be my own mistakes and not related to the makefile. Thanks again.
 
Old 02-09-2005, 05:04 PM   #6
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 438

Original Poster
Rep: Reputation: 30
Actually, I'm still getting an error:

Code:
bash-2.03$ make
/usr/local/bin/g++  -Wall -ftemplate-depth-25 '-I/usr/local/LEDA-4.3.1/incl/CGAL/config/sparc_SunOS-5.7_g++-2.95.3' -DCGAL_USE_LEDA -DLEDA_PREFIX '-I/usr/local/LEDA-4.3.1/incl' '-I/usr/local/include/LEDA-4.3.1/incl'  -g -c main.C
make: *** No rule to make target `flow_edge(BJ_EXT)', needed by `main'.  Stop.
bash-2.03$
Here is the simple main.C file I'm using to test this:

Code:
bash-2.03$ more main.C
#include <LEDA/graph.h>
#include <string>
#include "flow_edge.h"
#include "flow_node.h"

int main()
{
  //define parameterized directed graph   
  GRAPH<flow_node, flow_edge> G;

  
  return 0;
}
Any ideas?

Thanks again for all your help.
 
Old 02-09-2005, 05:11 PM   #7
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 438

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by Mara
It looks that I misses one thing. Try this version:
Code:
main$(EXE_EXT): main$(OBJ_EXT) flow_edge($OBJ_EXT) flow_node($OBJ_EXT)
	$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)main main$(OBJ_EXT) flow_edge($OBJ_EXT) flow_node($OBJ_EXT) $(LDFLAGS) -lm
If it fail, please post errors you get.
I think I fixed it. In your above code, I pulled the $ outside of the parentheses for all flow_edge and flow_node
and that seemed to work.
So flow_edge($OBJ_EXT) changed to flow_edge$(OBJ_EXT) etc., and that seemed to work.

Thanks again.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding additional drive to make a RAID 1 config khooke Linux - Hardware 2 09-25-2005 12:39 AM
makefile targets dand Programming 1 07-11-2005 03:28 PM
tinkering with dkms: make error no targets. Makefile issue? Emmanuel_uk Linux - Newbie 1 06-03-2005 01:26 AM
make with multiple targets eskimo22 Programming 1 02-26-2004 11:42 AM
DoomJuice worm targets M$ LinuxLala General 2 02-10-2004 06:58 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration