NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Unable to use NerdKits lcd.h file in AVRStudio
January 20, 2010 by banerjen |
Hello, I'm unable to import the lcd.h header file in AVRStudio. I copied the libnerdkits folder to the include folder of WinAVR. The C file compiled just fine but when I tried to build it, then it gave me a couple of errors - C:UsersNandanDocumentsLCD_UART_32default/../LCD_32.c:17: undefined reference to `lcd_init' C:UsersNandanDocumentsLCD_UART_32default/../LCD_32.c:19: undefined reference to `lcd_write_string' Regards, Nandan. |
---|---|
January 20, 2010 by N3Roaster |
Those are linker errors. That means that the compiler found the lcd.h file just fine, but lcd.o isn't getting passed to the linker along with the rest of your program. I'm not familiar with AVRStudio, so I can't really advise further, but perhaps knowing what the problem is will help you discover a solution. The nasty hacky solution which should work but which I do NOT recommend would be to copy the contents of lcd.c into your own program. |
January 26, 2010 by banerjen |
Thanks N3Roaster. Guess I will have to copy the contents of the lcd.h file. Nandan. |
January 26, 2010 by N3Roaster |
No, not the .h file, the .c file. The .h file only has function prototypes. Those let the compiler do type checking on the parameters you're passing to the functions but does not contain the implementation of those functions. Since the compiler is working (otherwise the linker wouldn't be run to give you those errors), it's clearly finding the header just fine. The .c file contains the implementation of those functions which would ordinarily be compiled into lcd.o and the linker takes that and the .o file the compiler produces from your code and hooks your function calls to the functions. Copying lcd.h into your program will not fix anything, but copying the contents of the .c file can solve this. That said, the real solution here is to figure out why your build system isn't passing lcd.o to the linker. Since lcd.c calls functions that are in delay.c (and would be compiled to delay.o), you'd likely just end up with new linker errors and end up copying code from there as well. Try this first:
The problem is almost certainly that those .o files are not where the build system expects them. Perhaps rather than copying libnerdkits you moved it (and thus those files are no longer where they belong) or your new project is not in the Code folder with the other projects. |
January 27, 2010 by banerjen |
No, I tried it. It didn't work. And yes, I meant the lcd.c file. I copied everything and it was giving an error stating that the NOP function was not recognized and a few more of such errors. And, I tried copying everything into one folder as you mentioned but it just didn't work. :( Nandan. |
January 27, 2010 by treymd |
aftter compilation, a program called the linker needs to find all the separate *.o files that will eventually be used to construct your binary, and take all the functions out of their respective .o files and move them to the binary. This, if you were using gcc on the command line using the included Makefile is taken care of for you. One of 2 things probably needs to happen. Either in your project settings you need to point the linker to the file lcd.o, or alternatively, you could try to find a way to have AVRStudio use the Makefile included by NerdKits. Also, I think GCC/GLibc is actually not installed by default in an AVRStudio installation, that could be problematic in the end because I believe libnerdkits depends upon the avr version of glibc. |
September 12, 2010 by msjones28021 |
I had the same problem and here was my fix: Be sure to modify "Makefile" in the "Programmer's Notepad" program if you use Windows. I edited this apparently in another program and the line that should have started out: LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o Got moved up one line and the programmer wasn't referencing the lcd.o files. This fixed my problem with the above, not sure if it will fix yours. |
Please log in to post a reply.
Did you know that a motor's no-load current at a given voltage is much less than it's resistance would suggest? Learn more...
|