Page 1 of 1

Undefined reference problems

Posted: Sun Apr 14, 2013 7:37 pm
by bkovac
Ok, so i wanted to compile my program which uses vusb and this error always comes up:

Code: Select all

usbdrv/usbdrv.o: In function `usbPoll':
usbdrv.c:(.text+0x132): undefined reference to `usbDescriptorHidReport'
usbdrv.c:(.text+0x134): undefined reference to `usbDescriptorHidReport'
usbdrv.c:(.text+0x256): undefined reference to `usbEventResetReady'

i tried both with older and newer versions of the library, multiple makefiles, but nothing

Re: Undefined reference problems

Posted: Mon Apr 15, 2013 9:15 pm
by vouvoume
There are two ways of compiling this.
The parameter "USB_PUBLIC" (usbconfig.h) decides what to use.

(A)
The classical thing is linking the usbdrv to your firmware. Therefore the usbdrv.c needs to be compiled into usbdrv.o and is fianlly linked.
This is safe and sound way - good programming practice.

(B)
The other way is including usbdrv into your main-project C-file. Therefore usbdrv.c is not compiled as stand alone, but instead all functions of the driver "appear" to be part of your main file.
This saves a little bit of programm space, since all-static code does not need to be position independed and is compiled a little-bit smaller:

#if (USB_PUBlIC==static)
#include <usbdrv.c>
#endif
#include <usbdrv.h>


If you need an example for (A) you can look into the firmware-part of the VUSB-example of:
http://matrixstorm.com/avr/tinyusbboard/#examples

("VUSB skeleton/example with corresponding linux, windows (delphi) and platform independent GTK libusb program")

Have fun!