The problem is this: gcc -shared --dll mydll.o --entry DllMain -o mydll.dll Your entry point should be DllMain@12 or _DllMain@12 (I don't remember if gcc adds the underscore for you or not).