includeing not working...

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey all, I just got my new LCD today from sparkfun, it is KS006U based and I hear it works fine with the HD what ever one, so I downloaded peter flurys LCD lib and Im testing on a mega16 so I changed the main LCD port from what ever it was to D and hooked it all up properly, changed the test_lcd file button to A or what ever I did thats not the prob... the prob is winAVR is not letting me compile because I dont think its seeing the LCD.h file as included.!!1 iv been dorking with it all day no luck.

heres my errors

C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:52: undefined reference to `lcd_init'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:60: undefined reference to `lcd_clrscr'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:63: undefined reference to `lcd_puts'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:66: undefined reference to `lcd_puts'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:69: undefined reference to `lcd_gotoxy'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:72: undefined reference to `lcd_putc'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:83: undefined reference to `lcd_command'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:86: undefined reference to `lcd_puts'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:96: undefined reference to `lcd_clrscr'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:99: undefined reference to `lcd_puts_p'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:100: undefined reference to `lcd_puts_p'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:103: undefined reference to `lcd_command'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:109: undefined reference to `lcd_command'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:116: undefined reference to `lcd_clrscr'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:122: undefined reference to `lcd_puts'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:132: undefined reference to `lcd_clrscr'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:134: undefined reference to `lcd_puts'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:140: undefined reference to `lcd_command'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:143: undefined reference to `lcd_data'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:148: undefined reference to `lcd_gotoxy'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:151: undefined reference to `lcd_putc'
C:\Documents and Settings\Owner\My Documents\winAVR Projects\_Tools and Examples\lcd/test_lcd.c:152: undefined reference to `lcd_putc'

the file is included fine. there is no error saying lcd.h isent found so I dont know what the hell is going wrong but its really starting to get me mad! any ideas? (this is not the first time this has happned, I dont normaly use .h files when I code I usly just use one big one, but sence I updated to the latest winAVR iv noticed sometimes it will build with inlcudes sometimes it wont.

the func prototypes are defined fine within lcd.h, I downloaded straight from his site. only changed pin settings. and makefile.

in lcd.h
extern void lcd_putc(char c);

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

anyone know?? Now im trying to play with a 1wire lib and I still cannot use functions outside of the main file!! do I need to include the external files in my makefile now or what? I tryed downgrading my winAVR still no luck.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The include file worked: it got you the correct declarations, so the
compiler didn't complain about unknown functions.

However, you have to link *all* object modules, not just your own.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

say wha? I have never had to do anything differnt before I dont think? so how do I link *all* object modules?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Make sure all relevant .o's are all presented on the instruction to the linker. If you are using an Mfile generated Makefile then it's basically just a case of making sure all the .c files that provide the functions involved (such as lcd_puts() etc.) are listed on the SRC= line

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm having the same problem, but I'm a little confused by the comment in the make file.

# List C source files here. (C dependencies are automatically generated.)
SRC = $(TARGET).c

Doesn't this mean that we shouldn't have to list all the C files if we include the header file in the TARGET?

Aaron[/code]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, that's not a correct conclusion to draw.

"C Dependencies are automatically generated" means something other than what you seem to think.

It means that the make system can intelligently determine whether anything has changed inside each listed C source file since the last time its corresponding ".o" file was built, and only those files which have changed will be rebuilt.

What constitutes a "change"?
Effectively, it amounts to a change in the timestamp of the C file itself, or of any files which are #included inside it.

Since well-behaved programmers never embed ".c" files within other ".c" files, it is necessary to list each of the individual ".c" files in the makefile, so that make knows which files to consider for re-building and linking.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm having the same problem:
* build output:

rm -rf keyb.o main.o  vib.elf dep/* vib.hex vib.eep vib.lss vib.map
Build succeeded with 0 Warnings...
avr-gcc.exe  -mmcu=attiny25 -Wall -gdwarf-2             -DF_CPU=8000000UL -Os -fsigned-char -MD -MP -MT keyb.o -MF dep/keyb.o.d  -c  ../keyb.C
avr-gcc.exe  -mmcu=attiny25 -Wall -gdwarf-2             -DF_CPU=8000000UL -Os -fsigned-char -MD -MP -MT main.o -MF dep/main.o.d  -c  ../main.c
avr-gcc.exe -mmcu=attiny25  keyb.o main.o     -o vib.elf
main.o: In function `main':
../main.c:97: undefined reference to `KeyboardInit'
../main.c:124: undefined reference to `Keyboard'
make: *** [vib.elf] Error 1
Build failed with 2 errors and 0 warnings...

* main.C:

#include 
...
#include "keyb.h"
...
int main(void)
{
...
   Keyboard();
...
}

* keyb.C:

...
#include "keyb.h"
...
void Keyboard(void)
{
...
}

* keyb.h:

extern void Keyboard(void);
...

* Makefile (automatically generated):

###############################################################################
# Makefile for the project vib
###############################################################################

## General Flags
PROJECT = vib
MCU = attiny25
TARGET = vib.elf
CC = avr-gcc.exe

## Options common to compile, link and assembly rules
COMMON = -mmcu=$(MCU)

## Compile options common for all C compilation units.
CFLAGS = $(COMMON)
CFLAGS += -Wall -gdwarf-2            -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d 

## Assembly specific flags
ASMFLAGS = $(COMMON)
ASMFLAGS += $(CFLAGS)
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2

## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS +=  -Wl,-Map=vib.map


## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom

HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings


## Include Directories
INCLUDES = -I"C:\Project\vib\default" -I"C:\Project\vib\." 

## Objects that must be built in order to link
OBJECTS = main.o keyb.o 

## Objects explicitly added by the user
LINKONLYOBJECTS = 

## Build
all: $(TARGET) vib.hex vib.eep vib.lss size

## Compile
main.o: ../main.c
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<

keyb.o: ../keyb.C
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<

##Link
$(TARGET): $(OBJECTS)
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)

%.hex: $(TARGET)
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@

%.eep: $(TARGET)
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0

%.lss: $(TARGET)
	avr-objdump -h -S $< > $@

size: ${TARGET}
	@echo
	@avr-size -C --mcu=${MCU} ${TARGET}

## Clean target
.PHONY: clean
clean:
	-rm -rf $(OBJECTS) vib.elf dep/* vib.hex vib.eep vib.lss vib.map


## Other dependencies
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)

* Program version:

AVR Studio		4.13.522  
GUI Version		4, 13, 0, 522
JTAGICE mkII		1, 0, 1, 140
ATTINY25		154

Operating System
Major			5
Minor			1
PlatformID		2
Build			2600
Service Pack 1

Plugins:

AvrLcdPlugin		1, 0, 0, 13
AvrPluginAvrAsmObject	1, 0, 0, 45
AvrPluginavrgccplugin	1, 0, 0, 7
Stk500Dll			1, 0, 1, 0

* Directory tree:

c:\project\vib\keyb.C
c:\project\vib\main.C
c:\project\vib\keyb.h
c:\project\vib\main.h
c:\project\vib\default\Makefile
c:\project\vib\default\keyb.o
c:\project\vib\default\main.o
c:\project\vib\default\dep\keyb.o.d
c:\project\vib\default\dep\main.o.d

WinAVR is installed in: "c:\Program files\Atmel\WinAVR"

IAR Embedded Workbench compiles and links the same source files perfectly (replacing compiler specific include files like )

Maybe spaces in WinAVR install folder (c:\Program files\...) are causing this error?

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

keyb.C is a C++ file, while main.c is a C file. Thus, keyb.C will
be compiled into so-called "mangled" function names (that include
argument type information), that's the reason why the linker cannot
find the referenced functions then.

Rename keyb.C into keyb.c (*in particular* within the Makefile --
the on-disk name is basically unimportant as the Win32 API is
case-insensitive for filename lookups).

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you! :D