Of course I don't know if this is the best way, or even the right way to go about it, but it gets rid of the errors for me. It seems a shame that you have to define the include paths and the CPU frequency twice: if there's some global way to do it, I can't find it.
- Download and unzip the latest version of the V-USB source code. Take a note of which example you are going to start with, because you need to get to the files in the /firmware folder for that example.
- Make a new project in Atmel Studio 6 with File / New / Project. Select "GCC C Executable project" and your target processor, and give it a sensible name.
- Copy and paste the code from the main.c that came with V-USB for your chosen example into the main.c that Atmel Studio creates (it will be called yourpojectname.c and should be open on the screen in front of you).
- Go to the Project menu. (The name of your project should appear on that menu with Properties after it. If it doesn't, it's because you currently have a file open that is not part of your project.) Select Project / (Name of your project) Properties / Toolchain tab / AVR/GNU C Compiler / Directories / Include path and add the path to where where the firmware/usbdrv folder is for your chosen example.
- You will need to do the same for the assembler. So… AVR/GNU Assembler / General / Include paths.
- Now you will get errors like "variable 'usbDescriptorDevice' must be const in order to be put into read-only section by means of '__attribute__((progmem))". So go and add const to the start of every line there is a complaint about. Changes may be necessary in usbdrv.h, usbdrv.c and your main C program.
- Copy usbconfig.h from the example project to your own project folder. At some point you will need to go in and check / change this file, but let's at least get things to compile.
- You will now get errors "undefined reference to `usbMsgPtr'", and similar. Go to the "solution explorer" pane in the top right of your screen, right-click on the name of your project, then select Add / Existing item. Navigate to usbdrv.c (which will be in the firmware/usbdrv folder for your chosen example) and add it.
- While you're there, also add:
usbdrvasm.asm
usbdrvasm.S
usbportability.h
- Now you will get a lot more const error messages generated by usbdrv.c so go and fix those.
- Next you get a F_CPU not defined error. This is because normally it is defined in the makefile. So go to Project / Properties / AVR/GNU C Compiler / Symbols / Defined symbols -D and add F_CPU=12000000 or whatever frequency you are using.
- As before you need to do this for assembler too. So back to Project / (Your project name) Properties / Toolchain / Assembler / General / Assembler flags and add -DF_CPU=12000000 because if you don't do this second step, you'll get an error message "USB_CFG_CLOCK_KHZ is not one of the supported non-crc-rates!"
Bingo.
(edit)
Fuses
One final note. If you are using Atmel Studio 6 then are you are likely using another utility to program your ATMega and set the fuses. With the default V-USB that you downloaded, this is all done for you by the makefile. So, you have another step to do.
Work out the fuse settings (you can probably use the default value you find in the V-USB makefile, but check to be sure) and program this using your ATMega utility (probably avrdude, or a GUI for it).
Beware: the fuses are inverted.
So SPIEN (enable serial programming) is actually set to 0, not 1, to "program" the fuse and enable serial programming. But if you use an online fuse calculator, or a GUI to set the fuses, they probably invert the logic again: so for SPIEN you check the checkbox to enable programming, which sets the fuse to 0, which because the fuses are inverted actually does enable the serial programming.