Stuck trying to use V-USB

I've been at this for ages . Trying to compile the code below and getting a verbose listing below that with the final error messages. I suspect V-USB needs compiling but I thought that happened on startup if you put it in the libraries ?

It does not find the functions ?
I put V-USB into the libraries and I thought it got compiled on Arduino IDE opening ?
Its just not finding the functions and I suspect they are not compiling or its an error with version 1.0.1

Can anyone help?

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>

#include "usbdrv.h"

#define F_CPU 16000000L
#include <util/delay.h>

USB_PUBLIC uchar usbFunctionSetup(uchar data[8]) {
        return 0; // do nothing for now
}

int main() {
        uchar i;

    wdt_enable(WDTO_1S); // enable 1s watchdog timer

    usbInit();
        
    usbDeviceDisconnect(); // enforce re-enumeration
    for(i = 0; i<250; i++) { // wait 500 ms
        wdt_reset(); // keep the watchdog happy
        _delay_ms(2);
    }
    usbDeviceConnect();
        
    sei(); // Enable interrupts after re-enumeration
        
    while(1) {
        wdt_reset(); // keep the watchdog happy
        usbPoll();
    }
        
    return 0;
}

This is verbose output

/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard -I/mnt/home/TempStore/sketchbook/libraries/usbdrv /mnt/home/TempStore/sketchbook/build/VUSBExample1.cpp -o /mnt/home/TempStore/sketchbook/build/VUSBExample1.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-gcc -c -g -assembler-with-cpp -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=101 -DUSB_VID=null -DUSB_PID=null -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard -I/mnt/home/TempStore/sketchbook/libraries/usbdrv -I/mnt/home/TempStore/sketchbook/libraries/usbdrv/utility /mnt/home/TempStore/sketchbook/libraries/usbdrv/usbdrvasm.S -o/mnt/home/TempStore/sketchbook/build/usbdrv/usbdrvasm.S.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard -I/mnt/home/TempStore/sketchbook/libraries/usbdrv -I/mnt/home/TempStore/sketchbook/libraries/usbdrv/utility /mnt/home/TempStore/sketchbook/libraries/usbdrv/usbdrv.c -o /mnt/home/TempStore/sketchbook/build/usbdrv/usbdrv.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard -I/mnt/home/TempStore/sketchbook/libraries/usbdrv -I/mnt/home/TempStore/sketchbook/libraries/usbdrv/utility /mnt/home/TempStore/sketchbook/libraries/usbdrv/oddebug.c -o /mnt/home/TempStore/sketchbook/build/usbdrv/oddebug.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/wiring_analog.c -o /mnt/home/TempStore/sketchbook/build/wiring_analog.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/wiring_shift.c -o /mnt/home/TempStore/sketchbook/build/wiring_shift.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/wiring.c -o /mnt/home/TempStore/sketchbook/build/wiring.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/wiring_digital.c -o /mnt/home/TempStore/sketchbook/build/wiring_digital.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/wiring_pulse.c -o /mnt/home/TempStore/sketchbook/build/wiring_pulse.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-gcc -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/WInterrupts.c -o /mnt/home/TempStore/sketchbook/build/WInterrupts.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/main.cpp -o /mnt/home/TempStore/sketchbook/build/main.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/Print.cpp -o /mnt/home/TempStore/sketchbook/build/Print.cpp.o 
/arduino-1.0.1/hardware/arduino/cores/arduino/Print.cpp: In member function 'size_t Print::print(const __FlashStringHelper*)':
/arduino-1.0.1/hardware/arduino/cores/arduino/Print.cpp:44: warning: '__progmem__' attribute ignored
/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/HID.cpp -o /mnt/home/TempStore/sketchbook/build/HID.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/new.cpp -o /mnt/home/TempStore/sketchbook/build/new.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/Stream.cpp -o /mnt/home/TempStore/sketchbook/build/Stream.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/HardwareSerial.cpp -o /mnt/home/TempStore/sketchbook/build/HardwareSerial.cpp.o 
/arduino-1.0.1/hardware/arduino/cores/arduino/HardwareSerial.cpp:
[code]In function 'void store_char(unsigned char, ring_buffer*)':
/arduino-1.0.1/hardware/arduino/cores/arduino/HardwareSerial.cpp:82: warning: comparison between signed and unsigned integer expressions
/arduino-1.0.1/hardware/arduino/cores/arduino/HardwareSerial.cpp: In member function 'virtual size_t HardwareSerial::write(uint8_t)':
/arduino-1.0.1/hardware/arduino/cores/arduino/HardwareSerial.cpp:390: warning: comparison between signed and unsigned integer expressions
/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/WString.cpp -o /mnt/home/TempStore/sketchbook/build/WString.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/Tone.cpp -o /mnt/home/TempStore/sketchbook/build/Tone.cpp.o 
/arduino-1.0.1/hardware/arduino/cores/arduino/Tone.cpp:108: warning: only initialized variables can be placed into program memory area
/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/CDC.cpp -o /mnt/home/TempStore/sketchbook/build/CDC.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/USBCore.cpp -o /mnt/home/TempStore/sketchbook/build/USBCore.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/WMath.cpp -o /mnt/home/TempStore/sketchbook/build/WMath.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -I/arduino-1.0.1/hardware/arduino/cores/arduino -I/arduino-1.0.1/hardware/arduino/variants/standard /arduino-1.0.1/hardware/arduino/cores/arduino/IPAddress.cpp -o /mnt/home/TempStore/sketchbook/build/IPAddress.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/wiring_analog.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/wiring_shift.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/wiring.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/wiring_digital.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/wiring_pulse.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/WInterrupts.c.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/main.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/Print.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/HID.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/new.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/Stream.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/HardwareSerial.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/WString.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/Tone.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/CDC.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/USBCore.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/WMath.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-ar rcs /mnt/home/TempStore/sketchbook/build/core.a /mnt/home/TempStore/sketchbook/build/IPAddress.cpp.o 
/arduino-1.0.1/hardware/tools/avr/bin/avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o /mnt/home/TempStore/sketchbook/build/VUSBExample1.cpp.elf /mnt/home/TempStore/sketchbook/build/VUSBExample1.cpp.o /mnt/home/TempStore/sketchbook/build/usbdrv/usbdrvasm.S.o /mnt/home/TempStore/sketchbook/build/usbdrv/usbdrv.c.o /mnt/home/TempStore/sketchbook/build/usbdrv/oddebug.c.o /mnt/home/TempStore/sketchbook/build/core.a -L/mnt/home/TempStore/sketchbook/build -lm 
VUSBExample1.cpp.o: In function `main':
VUSBExample1.cpp:22: undefined reference to `usbInit()'
VUSBExample1.cpp:35: undefined reference to `usbPoll()'

[/code]

Geez this one moves along quickly

You are going to need to post the library you are using.

Geez this one moves along quickly

Possibly because V-USB is designed for standalone atmega mpus, and not for Arduinos. You may get a better response on the V-USB site's forum http://forums.obdev.at/viewforum.php?f=8.

rather than post the library here the library I am using is V-USB full specs of which are here

The library is downloaded and part of it (one directory "usbdrv") is placed in your sketchbook /library folder which then makes available the ".c" and ".h" files . You copy "usbconfig-prototype.h" and make a configuration file for yourself which is "usbconfig.h" which is also saved in that folder.

The program I am trying to compile is

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>

#include "usbdrv.h"

#define F_CPU 16000000L
#include <util/delay.h>

USB_PUBLIC uchar usbFunctionSetup(uchar data[8]) {
        return 0; // do nothing for now
}

int main() {
        uchar i;

    wdt_enable(WDTO_1S); // enable 1s watchdog timer

    usbInit();
        
    usbDeviceDisconnect(); // enforce re-enumeration
    for(i = 0; i<250; i++) { // wait 500 ms
        wdt_reset(); // keep the watchdog happy
        _delay_ms(2);
    }
    usbDeviceConnect();
        
    sei(); // Enable interrupts after re-enumeration
        
    while(1) {
        wdt_reset(); // keep the watchdog happy
        usbPoll();
    }
        
    return 0;
}

The problem I get is
VUSBExample1.cpp.o: In function main': VUSBExample1.cpp:22: undefined reference to usbInit()'
VUSBExample1.cpp:35: undefined reference to `usbPoll()'

http://forums.obdev.at/viewforum.php?f=8 I have a post there but it does not seem to get much response because they are not interested in Arduino IDE . They program direct to the chip.

It must be possible with Arduino I just need some knowlegeable person to look closely at the error and point me in the right direction.

I have managed to get it to compile with a bit of tinkering, but whether or not it works after what I have done I have no idea without properly studying the code (which at first glance appears that it was definitely not designed with Arduino in mind).

Part of the problem is that it is written in C not C++, and the compiler seems to be having a hissy fit with the files named .c - Don't know why, I'm not an expert. I have renamed them to .cpp and also changed all of the extern functions to be extern "C" which I believe tells the compiler to treat them as C functions - Again, not an expert.

I haven't got the hardware setup to test the modifications, but by all means try it out and see if it works. If not, V-USB are the best people to ask (or someone who knows C/C++ better - I have only been coding with C for 2 years).
http://www.railways-in-miniature.co.uk/electronics/arduino/usbdrv.zip

Thanks Tom-This thread moves along quickly -I missed this
Believe it or not I woke up this am with the same thought -to rename all "C" files to ".cpp" and see what happened on starting Arduino IDE

I had not even considered the "extern C" though
I D/L your changed files removed the ones I had in the library and fired up the IDE and program again with no change in the result unfortunately.

I will however keep studying it . It does not give an error message on start of the IDE so I am assuming it is compiling something - just have to find out what.

Right, I have got it working on my Mega1280. I will post instructions after a bit of testing.

Here is the usbdrv library and an example sketch
http://www.railways-in-miniature.co.uk/electronics/arduino/V-USB%20on%20Arduino.zip

Some notes:

  1. I redownloaded the usbdrv files and deleted the ones I modified before - the way I changed them was wrong.

  2. I realised that you don't need to rename the files to .cpp, you just have to include the header file as if it were a c type file:

extern "C"{
#include "usbdrv.h"
#if USE_INCLUDE
#include "usbdrv.c"
#endif
}
  1. There is a difference between the way C and C++ use pointer - specifically the C++ specification doesn't allow for the implicit conversion of (void*) pointers to type pointers (such as (usbRequest_t *)). These must be cast correctly. So in any of the examples where you find anything like:
usbRequest_t    *rq = (void*)data; 
//or
usbMsgPtr = (void*)&reportBuffer;

It needs to be changed to have the correct cast. In the two cases above it becomes:

usbRequest_t    *rq = (usbRequest_t *)data; 
//or
usbMsgPtr = (unsigned char *)&reportBuffer;
  1. Any implementations the the libraries extern functions must be written within the extern "C" {} block to specify they should be treated as C functions. (See the example sketch)

  2. You have to ensure your wiring is correct - USB runs at 3.3v level, which means your IC needs to run at 3.3v, or you need 3.6v zener diodes between D+ and GND, and between D- and GND. In the file above I have drawn the way I wired the board. In my case as I didn't have an zeners to hand, I used a pair of 1N4148 diodes in series with the +5v from the USB port and the arduino mega +5v rail. This forces the mega to run at just under 3.5V which is acceptable.

  3. If you use a different IC to the Mega, such as a Tiny chip or an Uno, you will need to use the corrent pins. D+ should be on the pin connected to INT0. D- doesn't matter which pin it is connected to. You also need to specify the port and bits you have chosen in the usbconfig.h file (under the heading "Hardware Config"):

/* ---------------------------- Hardware Config ---------------------------- */

#define USB_CFG_IOPORTNAME      D
/* This is the port where the USB bus is connected. When you configure it to
 * "B", the registers PORTB, PINB and DDRB will be used.
 */
#define USB_CFG_DMINUS_BIT      1
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
 * This may be any bit in the port.
 */
#define USB_CFG_DPLUS_BIT       0
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
 * This may be any bit in the port. Please note that D+ must also be connected
 * to interrupt pin INT0! [You can also use other interrupts, see section
 * "Optional MCU Description" below, or you can connect D- to the interrupt, as
 * it is required if you use the USB_COUNT_SOF feature. If you use D- for the
 * interrupt, the USB interrupt will also be triggered at Start-Of-Frame
 * markers every millisecond.]
  1. Then example sketch is a bit of fun. If all goes well when you plug it in, after a couple of seconds you should see the mouse moving round in circles. It may have to install the drivers first (generic USB mouse driver).

Gee thanks so much for the time you have put in Tom :grin:
I'll study that and get back to you.

My first run got this error on

if(usbInterruptIsReady()){
/* called after every poll of the interrupt endpoint /
advanceCircleByFixedAngle();
DBG1(0x03, 0, 0); /
debug output: interrupt report prepared */
usbSetInterrupt((unsigned char *)&reportBuffer, sizeof(reportBuffer));
}

Mouse:149: error: 'usbInterruptIsReady' was not declared in this scope
Mouse:153: error: 'usbSetInterrupt' was not declared in this scope
Mouse.cpp:158: warning: function declared 'noreturn' has a 'return' statement

This is declared on line 220 or so of usbdrv.h
I'm running this on a mega328p

Where did you put the usbdrv folder? It needs to go in the \libraries\ folder, not the documents folder otherwise it doesn't work.
Also did you delete the old usbdrv folder? Renaming it doesn't work as it still remembers the old files for some reason.

All I know for sure is the example sketch compiles fine for me.

Yes and yes.
Its getting through most of it just hanging on those two functions for some reason

Which version of the IDE are you using? I doubt it will make a difference, but I am trying to work out what could be different between your computer and mine as it works perfectly for me for both Uno and Mega.

Version 1.0.1
I'm using a Duemilanov board with 328p
I left usbconfig.h as you had it-I have made no changes anywhere atm
I have
binutils-avr_2.20
gcc-avr_4.5.3
avr-libc_1.6.7

Interesting. I have 1.0.1, but the GCC version is 4.3.2 - perhaps something has changed in the newer version of GCC which is causing issues.

Quite late in this discussion, but I have found an Arduino port of V-USB here: Google Code Archive - Long-term storage for Google Code Project Hosting.
It seems as if RancidBacon has wrapped the exported functions as follows to make them compatible with Arduino's C++ environment:

#ifdef __cplusplus
extern "C"{
#endif
USB_PUBLIC void usbInit(void);
USB_PUBLIC void usbPoll(void);
#ifdef __cplusplus
} // extern "C"
#endif

Christo:
Quite late in this discussion, but I have found an Arduino port of V-USB here: Google Code Archive - Long-term storage for Google Code Project Hosting.
It seems as if RancidBacon has wrapped the exported functions as follows to make them compatible with Arduino's C++ environment:

#ifdef __cplusplus

extern "C"{
#endif
USB_PUBLIC void usbInit(void);
USB_PUBLIC void usbPoll(void);
#ifdef __cplusplus
} // extern "C"
#endif

Thats the same thing I did 8).

There seem to be other changes too and other examples.
I d/l and used this library and the demos compiled OK but I don't know how to use the library yet.
That was the purpose here so I'll now endeavor to get a bit of a look at it -Thanks Christo

I would like to get your example up and running too Tom . Perhaps it will reveal itself with more study on my part -Thanks for the start