Is there any way I can use the same project file on both platforms, or Some way to make Code::Blocks figure out when to add -lmingw32? Or am I barking up entirely the wrong tree?
A very convenient way would be to use C::B's platform option in the project options.
I do it as following:
1.) create a target for Windows, set the platform to windows
2.) create atarget for linux, set the platform to linux
3.) create a virtual target "all" that contains both of the above (that's the target I am compiling under all platforms)
4.) setup common options on project level
5.) setup platform specific options at project level.
That's all. If you compile the virtual target "all", C::B will skip the windows target on Linux and vice versa.