NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » Error during compilation of tempsensor code

January 16, 2011
by jpower
jpower's Avatar

Hi all,

I'm having trouble compiling the tempsensor project code. I'm fairly certain the problem isn't in the .c file itself, as the same problem occurs when attempting to compile the pre-written file that came with the nerdkits download.

Here's what I'm getting:

make -C ../libnerdkits
make[1]: Entering directory `C:/WinAVR-20090313/Code/libnerdkits'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `C:/WinAVR-20090313/Code/libnerdkits'
avr-gcc -g -Os -Wall -mmcu=atmega168  -Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm -o tempsensor.o tempsensor.c ../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o
tempsensor.c: In function 'main':
tempsensor.c:69: warning: implicit declaration of function 'FDEV_SETUP_STREAM'
tempsensor.c:69: error: '_FDEV_SETUP_WRITE' undeclared (first use in this function)
tempsensor.c:69: error: (Each undeclared identifier is reported only once
tempsensor.c:69: error: for each function it appears in.)
tempsensor.c:69: error: invalid initializer
tempsensor.c:77: error: '_FDEV_SETUP_RW' undeclared (first use in this function)
tempsensor.c:77: error: invalid initializer
tempsensor.c:78: error: lvalue required as left operand of assignment
tempsensor.c:104: warning: implicit declaration of function 'fprintf_P'
tempsensor.c:109: warning: implicit declaration of function 'printf_P'
make.exe: *** [tempsensor.hex] Error 1

> Process Exit Code: 2
> Time Taken: 00:01

The error seems to result from the first line of the makefile:

GCCFLAGS=-g -Os -Wall -mmcu=atmega168

But I've no idea what any of that means...

If it helps, I'm using windows Vista, according to the installation steps recommended by the Nerdkits team.

Does anyone have any idea what's going wrong?

Cheers!

J

January 16, 2011
by Rick_S
Rick_S's Avatar
  1. When you downloaded the code folder from the member area, did you leave the folder structure intact or did you pull the tempsensor folder out by itself. The structure must be left intact to compile as written.
  2. Try re-downloading and unzipping the code folder on the root of your hard drive so the folder is C:\Code with all it's sub-folders below.

The makefile expects the files to be in certain places in relationship to each other. If that folder structure isn't there, you will not be able to complile because critical components of the code will be missing.

January 17, 2011
by jpower
jpower's Avatar

Thanks Rick, I originally extracted the entire 'Code' folder tree into the WinAVR directory, and the complilation of the 'initiaload' program worked just fine from there.

I tried your suggestion and redownloaded+extracted the nerdkits sample source code to C:Code, but the same problem is still occuring.

I triple checked that I was using the code from the C:Codetempsensor folder.

Any other ideas?

January 17, 2011
by Rick_S
Rick_S's Avatar

It's odd to get that error with fresh files. Typically that error would be generated if the include for stdio.h wasn't around. Just for curiosity, does your initialload file still complile? I'm beginning to suspect the environment for WINAVR isn't right. The Windows environment System PATH variables have to be set for make to find the WinAVR includes. It sounds like they are not set right.

When you installed WinAVR, did you right click and install as administrator? For it to install proplerly, that needs to be done. Even if you did, maybe uninstall and reinstall WinAVR, it'd only take a few minutes and may cure your woes.

If that doesn't, maybe someone else can pop in and provide suggestions.

January 20, 2011
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Jpower,

Did this problem get resolved? It is definitely strange that you get this error with a fresh copy of the code. It could point to a wonky install of WinAVR. Could there be some sort of permissions issue you are running into?

Humberto

January 20, 2011
by jpower
jpower's Avatar

Thanks for the suggestion guys :) I haven't tried it yet, but I'll give it a go before tomorrow afternoon and let you know how it plays out.

Also Rick, the initiaload file still compiles just fine.

Cheers,

Josh

January 23, 2011
by jpower
jpower's Avatar

Hi guys, I uninstalled winAVR and reinstalled using 'run as admin', but I'm still encountering the same problem.

Can you recommend another compiler that would work with your files?

Thanks,

Josh

January 23, 2011
by hevans
(NerdKits Staff)

hevans's Avatar

Hi jpower,

This is a very strange problem you are having. Although there are other tool chains available out there I would like to have you setup and working with this one since it is the one we all know and can help you work with.

I am confused by the fact that your initialload works fine. Could you go into the initialload folder and delete all the .o and .hex files in there, and try compiling again.

Just so we can make absolutely sure could you post the first 10 lines or so of your tempsensor.c file. I'd like to make sure the proper includes are there.

Humberto

January 25, 2011
by jpower
jpower's Avatar

Hi Humberto,

I deleted the .o and .hex files in the initiaload directory, and the program still compiled just fine. The original problem is still occuring with the tempsensor program.

Here are the include lines from the tempsensor file:

#define F_CPU 14745600

#include <stdio.h>
#include <math.h>

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <inttypes.h>

#include "../libnerdkits/delay.h"
#include "../libnerdkits/lcd.h"
#include "../libnerdkits/uart.h"

// PIN DEFINITIONS:

Would including the contents of the makefile help also?

Thanks,

Josh

January 25, 2011
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Josh,

The includes look intact. Go ahead and post the contents of the Makefile for us too. The problem may be in there.

Humberto

January 31, 2011
by jpower
jpower's Avatar

Thanks again guys,

Here's the makefile:

GCCFLAGS=-g -Os -Wall -mmcu=atmega168 
LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm
AVRDUDEFLAGS=-c avr109 -p m168 -b 115200 -P COM3
LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

all:    tempsensor-upload

tempsensor.hex: tempsensor.c
    make -C ../libnerdkits
    avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o tempsensor.o tempsensor.c ${LINKOBJECTS}
    avr-objcopy -j .text -O ihex tempsensor.o tempsensor.hex

tempsensor.ass: tempsensor.hex
    avr-objdump -S -d tempsensor.o > tempsensor.ass

tempsensor-upload:  tempsensor.hex
    avrdude ${AVRDUDEFLAGS} -U flash:w:tempsensor.hex:a

I hope this helps!

Josh

February 03, 2011
by rampraba
rampraba's Avatar

Hi,

I am trying to compile the 'tempsensor" code but i am getting a error message as

'_FDEV_SETUP_WRITE'undeclared and subsequently '_FDEV_SETUP_RW'. Kinldy let me how to resolve this error message. I could able to successfully compile Led_blink.

Thanks, Ram

February 03, 2011
by rampraba
rampraba's Avatar

Hi,

This is regarding my earlier post on the error message while compiling tempsensor. "FDEV_SETUP_WRITE" undeclared. I tried to copy the stdio.h file to libnerdkits and declared it in the tempsensor file and it worked fine. I could able to compile tempsensor successuly. I already have a c compiler in the computer and while compiling the system i think it is trying to access the standard stdio and not the avr stdio.h file.

Thanks, Ram

February 03, 2011
by rampraba
rampraba's Avatar

Hi Josh,

I think you already have a c compiler in your system. Try copying the stdio.h file from avr and paste it in libnerdkits and declare it in the tempsensor.c file.

include "../libnerdkits/stdio.h". Add # symbol before include

and recompile it. It should work.

Thanks, Ram

February 12, 2011
by jpower
jpower's Avatar

Brilliant:)

Thanks Ram, that solved it just fine.

I do have another C compiler installed, that'd be a good one to keep an eye out for in future!

Post a Reply

Please log in to post a reply.

Did you know that you can make a capacitive proximity sensor with some aluminum foil and paperclips? Learn more...