MrBucket101
March 16th, 2009, 03:10 AM
For one of my classes I had to write a simple program in C that would calculate the number of paint cans to paint a persons pool given the dimensions.
Heres the source
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* main.c - Auto-generated by Anjuta's Makefile project wizard
*
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
int paintcoverage=200;
int main()
{
float length,width,height,wall1,bottom,wall2,totalarea;
int cansofpaint = 1;
printf("Please input the following in FEET\n");
printf("Length of your pool?\n");
scanf("%f",&length);
printf("Width of your pool?\n");
scanf("%f",&width);
printf("Depth of your pool?\n");
scanf("%f",&height);
bottom = length*width;
wall1 = height*width;
wall2 = height*length;
totalarea=bottom+wall1+wall2;
if(totalarea/paintcoverage < 1){
printf("The total area that you need to paint is %f feet.\n In order to paint this area you will need to buy 1 can of paint",totalarea);
}
float cansofpaintf = totalarea/paintcoverage;
cansofpaint = ceil(cansofpaintf);
printf("The total area that you need to paint is %f feet.\n In order to paint this area you will need to buy %i cans of paint",totalarea,cansofpaint);
return (0);
}
In Anjuta I can compile the program just fine. But when I goto execute it I get an error line 33 "undefined reference call to ceil"
However when I went to the command line and
gcc paintcans.c -lm
./a.out
The program compiled and executed perfectly.
Can anyone help? I really like anjuta and would prefer to keep using it.
EDIT: here is my makefile as well
## Created by Anjuta
CC = gcc
CFLAGS = -g -Wall
OBJECTS = Paintcans.o
INCFLAGS =
LDFLAGS = -Wl,-rpath,/usr/local/lib
LIBS =
all: Paintcans
Paintcans: $(OBJECTS)
$(CC) -o Paintcans $(OBJECTS) $(LDFLAGS) $(LIBS)
.SUFFIXES:
.SUFFIXES: .c .cc .C .cpp .o
.c.o :
$(CC) -o $@ -c $(CFLAGS) $< $(INCFLAGS)
count:
wc *.c *.cc *.C *.cpp *.h *.hpp
clean:
rm -f *.o
.PHONY: all
.PHONY: count
.PHONY: clean
Heres the source
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* main.c - Auto-generated by Anjuta's Makefile project wizard
*
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
int paintcoverage=200;
int main()
{
float length,width,height,wall1,bottom,wall2,totalarea;
int cansofpaint = 1;
printf("Please input the following in FEET\n");
printf("Length of your pool?\n");
scanf("%f",&length);
printf("Width of your pool?\n");
scanf("%f",&width);
printf("Depth of your pool?\n");
scanf("%f",&height);
bottom = length*width;
wall1 = height*width;
wall2 = height*length;
totalarea=bottom+wall1+wall2;
if(totalarea/paintcoverage < 1){
printf("The total area that you need to paint is %f feet.\n In order to paint this area you will need to buy 1 can of paint",totalarea);
}
float cansofpaintf = totalarea/paintcoverage;
cansofpaint = ceil(cansofpaintf);
printf("The total area that you need to paint is %f feet.\n In order to paint this area you will need to buy %i cans of paint",totalarea,cansofpaint);
return (0);
}
In Anjuta I can compile the program just fine. But when I goto execute it I get an error line 33 "undefined reference call to ceil"
However when I went to the command line and
gcc paintcans.c -lm
./a.out
The program compiled and executed perfectly.
Can anyone help? I really like anjuta and would prefer to keep using it.
EDIT: here is my makefile as well
## Created by Anjuta
CC = gcc
CFLAGS = -g -Wall
OBJECTS = Paintcans.o
INCFLAGS =
LDFLAGS = -Wl,-rpath,/usr/local/lib
LIBS =
all: Paintcans
Paintcans: $(OBJECTS)
$(CC) -o Paintcans $(OBJECTS) $(LDFLAGS) $(LIBS)
.SUFFIXES:
.SUFFIXES: .c .cc .C .cpp .o
.c.o :
$(CC) -o $@ -c $(CFLAGS) $< $(INCFLAGS)
count:
wc *.c *.cc *.C *.cpp *.h *.hpp
clean:
rm -f *.o
.PHONY: all
.PHONY: count
.PHONY: clean