User forums => Using Code::Blocks => Topic started by: Jyaif on April 24, 2008, 09:41:04 pm
Title: Different linker settings when compiling on different OS
Post by: Jyaif on April 24, 2008, 09:41:04 pm
Hi, I have a project that can be compiled under windows and Linux. The problem is that the windows version requires -mingw32 while the linux version doesn't. Every time I update from my SVN I have to manually remove/add the library. Is there a way to automatize this process?
Title: Re: Different linker settings when compiling on different OS
Post by: mariocup on April 24, 2008, 11:17:37 pm
Hi Jyaif,
a solution could be attaching a script to your build targets like:
Code
function SetBuildOptions(base) { if(PLATFORM == PLATFORM_MSW) { base.AddLinkerOption(_T("your windows option")); } else { base.AddLinkerOption(_T("your linux option")); } .. } // end of SetBuildOptions
Bye,
Mario
Title: Re: Different linker settings when compiling on different OS
Post by: Jyaif on April 25, 2008, 12:01:59 am
Fantastic, it works perfectly!
in my case, it was AddLinkLib that I needed ;)
Title: Re: Different linker settings when compiling on different OS
Post by: thomas on April 25, 2008, 09:47:32 am
There's also explicit platform support built-in if you need more than that, for example if you don't just want to change a compiler flag, but maybe also want to compile some platform-dependent files.
Create separate targets for different platforms where needed, and then go to the project's properties, which lets you choose a platform ("All" by default) for every build target.