News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

How to set up a project to build both static and dynamic libraries

Started by alexchen, December 06, 2013, 11:44:47 PM

Previous topic - Next topic

alexchen

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.

stahta01

Quote from: 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.

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

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Jenna

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.

dmoore

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.
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

alexchen

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.