Just to give the third method some love. There is a third method to export symbols, that is the linker's /export command line option. This can be put into a source file using the #pragma directive.
#pragma comment(linker, "/export:symbol")
But I'm only mentioning this because I think it is unfair that the MSDN documentaiton only mentions the .DEF file in the dllexport documentation.