Is there anyway to write dlls in linux? Do I have to install windows to write dlls in linux? Right now one of my courses are pretty retarded and requires me to write a dll for this.
You should take a look into 'shared libraries' http://www.linux.org/docs/ldp/howto/Program-Library-HOWTO/shared-libraries.html
Not really. Building any kind of executable intended for OS "A" while using OS "B" is a process commonly known as cross-compilation. In this partciluar case, you would need a cross-compiler running on Linux, but targetting Windows. I don't know any vendor selling such a product.
Your best bet is to write one in Windows, as that's the place where they are used and the compilers/tools are designed to support it. There's a lot of funky little compiler directives you need to use to compile a dll, and that's probably best done with a Win32 compiler, ideally VC++.
You could maybe use MinGW in Windows to compile the dll. That would give you the ability to use Linux-esque development tools in the process and make it less painful.
Lots of folks are getting near the right answer but not providing it: gcc can generate win32 PE/COFF files without problem, and of course can always build as a cross compiler on any platform it can target. The binutils port targets windows .exe and .dll files natively, and there's a "dlltool" utility for handling the edge cases where Unix and Windows linkage metaphors are different.
Additionally, the "mingw32" project provides a set of link libraries and header files for building C applications against the win32 API. These likewise install just fine on any Unix.
Here's a site I turned up after a quick google with instructions for building the toolchain.