Make file newby question

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Make file newby question
# 1  
Old 04-12-2011
Make file newby question

1. The problem statement, all variables and given/known data:
I'm brand new to make files, and I was hoping someone could tell me where I'm messing up.
I'm trying to build a cpp program I wrote for class on a linux system, i'm using winscp and puTTy.
The program works fine when I build it using the visual studios 2008 IDE, so the problem should be in my makefile I believe. My makefile and all files needed for the project are in the same directory. I would greatly appreciate any help, hopefully its a easy fix. Thanks in advance.


2. Relevant commands, code, scripts, algorithms:
Here is my make file:
# Make File For AHeapOfStudents Project
Code:
CC = g++ 
CFLAGS = -g  
CMD = AHeapOfStudents_exec 

OBJS = Main.o Student.o Address.o Date.o Name.o Proformance.o  
CCFILES = Main.cc Student.cc Address.cc Date.cc Name.cc Proformance.cc 
HFILES = Student.h Address.h Date.h Name.h Proformance.h 

$(CMD):	$(OBJS) 
        $(CC)  -o $(CMD) $(OBJS) 

Main.o:	Main.cc Student.h 
        $(CC) $(CFLAGS) -c Main.cc 

Student.o:	Student.cc Address.h Date.h Name.h Performance.h 
        $(CC) $(CFLAGS) -c Student.cc 

Address.o:	Address.cc Address.h 
        $(CC) $(CFLAGS) -c Address.cc 

Date.o:	Date.cc Date.h 
        $(CC) $(CFLAGS) -c Date.cc 
         
Name.o:	Name.cc Name.h 
        $(CC) $(CFLAGS) -c Name.cc 
         
Performance.o:	Performance.cc Performance.h 
        $(CC) $(CFLAGS) -c Performance.cc 

3. The attempts at a solution (include all code and scripts):
And here is the response when I attempt to build:
Code:

make Main 
g++     Main.cpp   -o Main 
In file included from Student.h:3, 
                 from Main.cpp:14: 
Address.h:30:7: warning: no newline at end of file 
In file included from Main.cpp:14: 
Student.h:37:7: warning: no newline at end of file 
/tmp/ccyPQFpG.o: In function `Alphabetize(Student*)': 
Main.cpp:(.text+0x1f34): undefined reference to `Student::GetSName()' 
Main.cpp:(.text+0x1f49): undefined reference to `Name::GetLastName()' 
Main.cpp:(.text+0x1fbc): undefined reference to `Student::GetSName()' 
Main.cpp: (.text+0x1fd1): undefined reference to `Name::GetLastName()' 
Main.cpp(.text+0x2041): undefined reference to `Student::GetSName()' 
Main.cpp:(.text+0x2056): undefined reference to `Name::GetFirstName()' 
Main.cpp:(.text+0x20c9): undefined reference to `Student::GetSName()' 
Main.cpp:(.text+0x20de): undefined reference to `Name::GetFirstName()' 
/tmp/ccyPQFpG.o: In function `SimplePrint(Student*, int)': 
Main.cpp:(.text+0x23c1): undefined reference to `Student::SimpleReport()' 
/tmp/ccyPQFpG.o: In function `Print(Student*, int)': 
Main.cpp:(.text+0x246b): undefined reference to `Student::Report()' 
/tmp/ccyPQFpG.o: In function `main': 
Main.cpp:(.text+0x2714): undefined reference to  `Name::SetFirstName(std::basic_string<char,  std::char_traits<char>, std::allocator<char> >)' 
Main.cpp:(.text+0x2787): undefined reference to  `Name::SetLastName(std::basic_string<char,  std::char_traits<char>, std::allocator<char> >)' 
Main.cpp:(.text+0x27dd): undefined reference to `Student::SetSName(Name)' 
Main.cpp:(.text+0x284d): undefined reference to  `Address::SetLine1(std::basic_string<char,  std::char_traits<char>, std::allocator<char> >)' 
Main.cpp:(.text+0x28bd): undefined reference to  `Address::SetLine2(std::basic_string<char,  std::char_traits<char>, std::allocator<char> >)' 
Main.cpp:(.text+0x292d): undefined reference to  `Address::SetCity(std::basic_string<char,  std::char_traits<char>, std::allocator<char> >)' 
Main.cpp:(.text+0x299d): undefined reference to  `Address::SetState(std::basic_string<char,  std::char_traits<char>, std::allocator<char> >)' 
Main.cpp:(.text+0x2a0b): undefined reference to `Address::SetZip(int)' 
Main.cpp:(.text+0x2a2f): undefined reference to `Student::SetSAddress(Address)' 
Main.cpp:(.text+0x2a98): undefined reference to `Date::SetDay(int)' 
Main.cpp:(.text+0x2ada): undefined reference to `Date::SetMonth(int)' 
Main.cpp:(.text+0x2b1c): undefined reference to `Date::SetYear(int)' 
Main.cpp:(.text+0x2b3f): undefined reference to `Student::SetSBirthDate(Date)' 
Main.cpp:(.text+0x2b79): undefined reference to `Date::SetDay(int)' 
Main.cpp:(.text+0x2bbb): undefined reference to `Date::SetMonth(int)' 
Main.cpp:(.text+0x2bfd): undefined reference to `Date::SetYear(int)' 
Main.cpp:(.text+0x2c20): undefined reference to `Student::SetSGradDate(Date)' 
Main.cpp:(.text+0x2c6e): undefined reference to `Performance::SetGPA(float)' 
Main.cpp:(.text+0x2cb0): undefined reference to `Performance::SetCredits(int)' 
Main.cpp:(.text+0x2ccf): undefined reference to `Student::SetSPerformance(Performance)' 
collect2: ld returned 1 exit status 
make: *** [Main] Error 1 
[martinmz@pegasus HeapOfStudents]$ 

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Indiana University Purdue University Indianapolis, Indianapolis(IN), Adrew J Harris, CSCI 240000 computing 2 and I'm not allow to include a link to the course.
# 2  
Old 04-13-2011
There's no error in your Makefile, but your invocation is a bit off. If you run make Main, make looks for a rule named "Main". If that can't be found, it checks for files named Main.{c,cpp,c++,...}, and applies a default rule to them which invokes the appropriate compiler, without any special options.

If you want to build the complete program, run make AHeapOfStudents_exec, or make Main.o if you only want to compile (not link) the source in Main.cpp.
# 3  
Old 04-13-2011
Also you can just run make. Since no target is given on the command line, make will look in the makefile for the first target and make that. A target is a line with a colon. Your first target line is $(CMD): $(OBJS) where CMD is a marco with the value "AHeapOfStudents_exec".
# 4  
Old 04-13-2011
I think you probably want to link all the objects into one file, hence why Main complains about so many missing symbols. You don't want Main, you want AHeapOfStudents_exec, which should include all of them.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read csv file, convert the data and make one text file in UNIX shell scripting

I have input data looks like this which is a part of a csv file 7,1265,76548,"0102:04" 8,1266,76545,"0112:04" I need to make the output data should look like this and the output data will be part of text file: 7|1265000 |7654899 |A| 8|12660000 |76545999 |B| The logic behind the... (6 Replies)
Discussion started by: RJG
6 Replies

2. Fedora

Newby: How to actually update software?!

Hi All - 1) I work with bigdate for a living, use lots of neat software, SAS, SQL Server, etc. I know how to get my data and such, analyze it, etc... 2) I use UNIX at work (Solaris mostly) and can easily navigate around Unix and get the job done, vi and sas -nodms are about my fav, and some... (6 Replies)
Discussion started by: sas
6 Replies

3. UNIX for Dummies Questions & Answers

Make Utility Question

Hello, I'm a recent convert to UNIX and I'm attempting to understand exactly how the make utility is working under the hood. Now, I understand that each rule has a target, dependencies, and update command, but the thing I'm confused about is exactly how the utility is determining when to... (1 Reply)
Discussion started by: kramer_102
1 Replies

4. UNIX for Dummies Questions & Answers

What difference does * make here ? (ls command question)

Solaris 10 (korn shell) I use -d option with ls command , when I want to suppress contents of the subdirectories being listed when listing all the directories and files in a directory. This is what man page says about -d option in ls command. -d If an argument is a directory,... (3 Replies)
Discussion started by: kraljic
3 Replies

5. Shell Programming and Scripting

Newby needs help from an OpenSSL expert

Dear friends, Thank you for reading this post. Please download files here: http://www.idanfe.com/dl/files.zip This is my problem: I have to sign a file like my teste1.txt One sample signed file is example.txt I am also including a private key I generated called... (4 Replies)
Discussion started by: fundidor
4 Replies

6. Shell Programming and Scripting

Question about a basic shell script: How to make sure it receives only one input?

Hello all! I am very new to shell and Linux in general (I just started 2 days ago), I am trying to write a script that adds the size of the directories and files in a given directory and displays messages if the user puts in something wrong. I think I have covered all the possible problems except... (3 Replies)
Discussion started by: 2358
3 Replies

7. Programming

A question about Makefile run by GNU make

Hello everybody, Currently I'm learning how to build projects (C programming) with GNU make. I have a problem with one Makefile and I would appreciate if you could kindly give me a hand. Here is the environment: OS: Redhat linux 5 compiler: gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)... (2 Replies)
Discussion started by: dariyoosh
2 Replies

8. Programming

makeutility: how to get the make-file name inside of the make-file?

How I can get the current make-file name in a make-file So, if I run make with specified file:make -f target.mak is it possible to have the 'target' inside of the that 'target.mak' from the file name? (2 Replies)
Discussion started by: alex_5161
2 Replies

9. Shell Programming and Scripting

compare two files and make 1st file same as 2nd file

I am trying to compare two file and make changes where ever its different. for example: Contents of file1 IP=192.165.89.11 NM=255.255.0.0 GW=192.165.89.1 Contents of file2 IP=192.165.89.11 NM=255.255.255.255 GW=192.165.89.1 NOTE HERE THAT NM IS DIFFERENT So i want the changes... (6 Replies)
Discussion started by: pradeepreddy
6 Replies

10. Shell Programming and Scripting

Help for a newby

I am new to using nawk. When I put the following line in script file test1.awk I get the results: { print NR, length($0),NF} >nawk -f test1.awk head.txt 1 63 5 2 2622 188 3 2166 155 4 3192 228 5 2679 192 ..... but if I modify the test1.awk file to look like this: BEGIN {FS = ","}... (2 Replies)
Discussion started by: placroix1
2 Replies
Login or Register to Ask a Question