User forums > Using Code::Blocks
Linking SDL (and others) in a cross-platform way
(1/1)
theOcelot:
I'm trying to set up my programming project so that I can use the same CB project file on both Linux and Windows. It's in an SVN repo on sourceforge.net; you can browse it here: http://somnopatru.svn.sourceforge.net/viewvc/somnopatru/.
Anyway, I've moved to using global vars to represent library locations, and I can compile the simple static library sub-project that only requires headers. The problem is that linking an SDL application on Linux requires different (fewer) options than with MinGW. MinGW requires "-lmingw32 -lSDLmain -lSDL", while on Linux I don't need -lmingw32 (obviously).
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?
I have a similar problem with Boost.FileSystem. On Windows I use -lboost_filesystem_mgw44-mt-d while on Linux it's just -lboost_filesystem. Does anyone have ideas for this? I know it's less of a Code::Blocks issue than a library setup one, but Code::Blocks may be able to help and I figured I may as well ask here.
Thanks.
MortenMacFly:
--- Quote from: theOcelot on November 06, 2009, 03:15:57 am ---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?
--- End quote ---
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.
Jenna:
I guess
--- Quote from: MortenMacFly on November 06, 2009, 06:34:46 am ---5.) setup platform specific options at project level.
--- End quote ---
should be:
5.) setup platform specific options at projecttarget level.
MortenMacFly:
--- Quote from: jens on November 06, 2009, 06:43:27 am ---5.) setup platform specific options at projecttarget level.
--- End quote ---
Indeed. Copy&Paste error. :lol:
theOcelot:
Perfect. Why didn't I think of that? Thank you both for your help.
Navigation
[0] Message Index
Go to full version