There are multiple ways to do this...
1) Create two targets: one for windows and one for linux:
1.1) Project->Properties->Build targets
1.2) Copy one target, rename it to for ex. windows and select windows in the platforms dialog
1.3) Copy one target, rename it to for ex. linux and select unix in the platforms dialog
1.4) Select the target on the left->Build options. Now you can add the libraries how you like
1.5) Now if you build on windows, select the windows target, or the virtual target "all" and codeblocks will build the windows target. If you are on unix, select the unix target or "all" and codeblocks will build the unix version....
2) Via scripting
2.1) Project->Build options->Select the project name on the left
2.2) Linker Settings->Other linker options
2.3) Add the squirrel script:
[[ if(PLATFORM == PLATFORM_MSW ) print(_("-lgdi32")); else if(PLATFORM == PLATFORM_X11 ) printf(_("-lX11")); ]]
be aware, this has to be in one line of the other liner options...
Option 2) is probably not the right way, because on unix and windows the binary files have different extensions, so you probably have to make different build targets, with different ouptut names anyway, so way 1) is probably the more secure way to go...