PDA

View Full Version : Anjuta IDE C problems



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

dwhitney67
March 16th, 2009, 10:57 AM
Edit your Makefile (that is, the Anjuta configuration that generates it) to include the -lm reference to the math library. The -lm should be added to LIBS.

MrBucket101
March 16th, 2009, 01:45 PM
Thank you!

I'm curious though. Will I need to manually edit my makefile everytime?

As an IDE shouldn't anjuta determine what libraries to load based upon my #includes?

dwhitney67
March 16th, 2009, 09:21 PM
Thank you!

I'm curious though. Will I need to manually edit my makefile everytime?

As an IDE shouldn't anjuta determine what libraries to load based upon my #includes?
You should only have to do it once for a particular project, however when starting a new project, you may need to edit the configuration again. I don't use Anjuta, or any other IDE for that matter, so this is only an educated guess that I am making.

mmix
March 16th, 2009, 11:07 PM
http://www.anjuta.org/documents/C/anjuta-advanced-tutorial/figures/aat_options_lib3ds.png (http://www.anjuta.org/anjuta.php?page=documentations&subpage=documents/C/anjuta-advanced-tutorial/index.html)

MrBucket101
March 16th, 2009, 11:46 PM
^^^

Do you happen to know what version that is? I can't seem to find that in my settings. I'm using anjuta from the default repos.

Would it be better to compile it from SVN?

mmix
March 17th, 2009, 12:42 PM
http://library.gnome.org/devel/anjuta-manual/stable/figures/project_target_details.png.en (http://library.gnome.org/devel/anjuta-manual/stable/project-config.html.en)