Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: alexchen on December 06, 2013, 11:44:47 pm

Title: How to set up a project to build both static and dynamic libraries
Post by: alexchen on December 06, 2013, 11:44:47 pm
Is there a way to set a project's 'Build Targets' property to generate both static (.a) and dynamic (.so) libraries in the same build in Linux?
It seems the only way to build static and dynamic libraries is to have separate projects.
Title: Re: How to set up a project to build both static and dynamic libraries
Post by: stahta01 on December 07, 2013, 12:07:37 am
Is there a way to set a project's 'Build Targets' property to generate both static (.a) and dynamic (.so) libraries in the same build in Linux?
It seems the only way to build static and dynamic libraries is to have separate projects.

Did you try separate targets?
If not, try that. No idea if it works; but, I really think it should work.

Tim S.
Title: Re: How to set up a project to build both static and dynamic libraries
Post by: Jenna on December 07, 2013, 12:08:33 am
You can have two seperate build targets and put them together in one virtual target, so both get build if you click on the build- or rebuild-button.
Title: Re: How to set up a project to build both static and dynamic libraries
Post by: dmoore on December 07, 2013, 12:46:56 am
And if they share the same object dir (and object files) gcc won't need to compile twice, it will just link both ways from the same objects.
Title: Re: How to set up a project to build both static and dynamic libraries
Post by: alexchen on December 07, 2013, 02:13:59 am
The original targets were 'Release' and 'Debug'.  I create 'ReleaseStatic' and rename 'Release' to 'ReleaseDynamic' so that a new virtual target 'Release' can invoke both. However, the variable name $TARGET_NAME is tied to 'ReleaseDynamic' instead of 'Release' when I build 'Release' target, and that messes up my pre-build script, which keys on this value to select either 'Release' or 'Debug', not 'ReleaseStatic', 'ReleaseDynamic', 'DebugStatic', or 'DebugDynamic'.

If there is a variable name that represent all the object files, Maybe I can add a 'post-build' script to build static libraries when the dynamic library is built.