Hello,
Because I have some OS specific code and I need to make my library cross-platform, I decided to use build-scripts so as to link the right libraries on the right OS.
But it seems that I didn't code well the build script: a library which would normally be linked under linux is linked under windows and so makes the compilation failed!
Here is part of my build-script:
function SetBuildOptions( compilerManager )
{
if( compilerManager.SupportsCurrentPlatform( PLATFORM_X11 ) )
{
compilerManager.AddLinkLib( _T("X11") );//for example
}
else if( compilerManager.SupportsCurrentPlatform( PLATFORM_WIN ) )
{
//other libraries
}
}
How to correctly do what I would like?
I use C::B 8.02 on Windows Vista.
Thank you for your help.
Try
function SetBuildOptions( compilerManager )
{
if( PLATFORM == PLATFORM_X11 )
{
compilerManager.AddLinkLib( _T("X11") );//for example
}
else if( PLATFORM == PLATFORM_MSW )
{
//other libraries
}
}
I think the wiki has an error in this case
See :
http://wiki.codeblocks.org/index.php?title=Scripting_commands#CompileOptionsBase (http://wiki.codeblocks.org/index.php?title=Scripting_commands#CompileOptionsBase)
But SupportsCurrentPlatform is implemented as:
bool CompileOptionsBase::SupportsCurrentPlatform() const
{
if(platform::windows)
return m_Platform & spWindows;
if(platform::unix)
return m_Platform & spUnix;
if(platform::macosx)
return m_Platform & spMac;
return false;
}
in compileoptionsbase.cpp.
That means it returns true on all supported platforms.
EDIT:
I just corrected the wiki in this point.