954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

library catalogue program

hey guys, i got an assingment due and i was wondering if you could please help me to debug this program.

5 files,
ass1.h
ass1.cpp
main.cpp
Makefile.txt (needs to be renamed to makefile for it to be used properly)
ass1.txt(needs to be renamed ass1.dat to be used[its the database for the books])

to be compiled for a linux environment

the files to be loaded needs to change from text to binary file type, i havnt been able to work out how to do that yet

Attachments ass1.cpp (2.05KB) ass1.h (0.55KB) main.cpp (1.88KB) Makefile.txt (0.17KB) ass1.txt (0.72KB)
Slavrix
Junior Poster in Training
70 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

no, we're not going to do that. We're certainly not going to sheepishly compile and run your code and fix it for you.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

Ask specific questions. Post your code here not as attachments. Read the forum rules etc...

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

well it was worth a try

i fixed it all now anyhow, except one thing, my makefile.

CC=g++

all:	ass1

ass1:	main.o ass1.o
	$(CC) main.o ass1.o -o ass1

main.o:	main.cpp ass1.h
	$(CC) -c main.cpp

ass1.o:	ass1.cpp ass1.h
	$(CC) -c ass1.cpp


there it is, and here is the error (im using SSH to compile with, its connected to uni servers running ubuntu)

$ make
make: Fatal error in reader: Makefile, line 3: Unexpected end of line seen

Slavrix
Junior Poster in Training
70 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

Try this

CC=g++
 
ass1:	main.o ass1.o
	$(CC) main.o ass1.o -o ass1
 
main.o:	main.cpp ass1.h
	$(CC) -c main.cpp
 
ass1.o:	ass1.cpp ass1.h
	$(CC) -c ass1.cpp
SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

still not working, error got bigger


mksh: Warning: newline is not last character in file Makefile
Current working directory /home/ug/q/nt647
make: Fatal error in reader: Makefile, line 3: Unexpected end of line seen

Slavrix
Junior Poster in Training
70 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

Try implicit rules

CC = g++
 
ass1: main.o ass1.o
	$(CC) main.o ass1.o -o ass1
 
main.o:	main.cpp ass1.h
 
ass1.o:	ass1.cpp ass1.h
SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

I just downloaded your files(.cpp & .h) and tried the Makefile. Makefile just works fine. The problem is with your codes.

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

??

that code there btw is out of date, i have almost completly re-written it all, (except the main.cpp)

i put all my code into one file and compiled it and it worked fine (my new stuff) but when i split it again, for the makefile to do its job, it didnt complie

Slavrix
Junior Poster in Training
70 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

Post your corrected codes(all .cpp and .h files). I will try them at my end with the Makefile.

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

ok, i got my makefile working, but there seems to still be an error that i cant find , int he code itself, if possible could you see if you could find it ?

dont forget to change the makefile.txt back to makefile (just a reminder :P )

the error im getting now is

main.cpp:1: error: stray '\239' in program
main.cpp:1: error: stray '\187' in program
main.cpp:1: error: stray '\191' in program

Attachments main.cpp (1.89KB) ass1.txt (0.72KB) ass1.h (1.03KB) ass1.cpp (7.68KB) Makefile.txt (0.15KB)
Slavrix
Junior Poster in Training
70 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

ok, fixed, that, now this error instead :"(


$ make
g++ -c main.cpp
g++ -c ass1.cpp
g++ main.o ass1.o -o ass1
Undefined first referenced
symbol in file
DisplayRecords() main.o
ld: fatal: Symbol referencing errors. No output written to ass1
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `ass1'


use that main

Attachments main.cpp (1.88KB)
Slavrix
Junior Poster in Training
70 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

That's a linker error. It seems that you don't have defination of DisplayRecords() .

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

yea, i jsut had a thoroguh read of it, and found teh problem, please come and shoot me where i stand

DisplayRecord();
DisplayRecords();

i mixed it up in one spot :)

the makefile problems i was haveing seemed to be coming from invisible characters, i got my mate to retype on on his linux and send to me and i used that fine

but yea mate, thnx again for ur help

Slavrix
Junior Poster in Training
70 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You