User forums > Using Code::Blocks
How can I use build scripts?
(1/1)
blend:
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:
--- Code: ---function SetBuildOptions( compilerManager )
{
if( compilerManager.SupportsCurrentPlatform( PLATFORM_X11 ) )
{
compilerManager.AddLinkLib( _T("X11") );//for example
}
else if( compilerManager.SupportsCurrentPlatform( PLATFORM_WIN ) )
{
//other libraries
}
}
--- End code ---
How to correctly do what I would like?
I use C::B 8.02 on Windows Vista.
Thank you for your help.
Jenna:
Try
--- Quote ---function SetBuildOptions( compilerManager )
{
if( PLATFORM == PLATFORM_X11 )
{
compilerManager.AddLinkLib( _T("X11") );//for example
}
else if( PLATFORM == PLATFORM_MSW )
{
//other libraries
}
}
--- End quote ---
I think the wiki has an error in this case
See :
http://wiki.codeblocks.org/index.php?title=Scripting_commands#CompileOptionsBase
But SupportsCurrentPlatform is implemented as:
--- Code: ---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;
}
--- End code ---
in compileoptionsbase.cpp.
That means it returns true on all supported platforms.
EDIT:
I just corrected the wiki in this point.
blend:
Thank you so much! It works like a charm now :D!
But if I do a cross-compilation from windows for linux, will it be correct?
Navigation
[0] Message Index
Go to full version