Search code examples
premake

Mixing Shared and Static Libraries


I'm using premake5 to build a complex application on multiple platforms. My application links against both static and shared/dynamic external libraries. There seems to be significant build chain dependencies that break premake generated 'gmake' make files in this case.

Case in Point:

If you mix shared and static libraries in premake 'link' statements, GCC seems to get confused and expect your shared library references to actually be static libraries. When it can't find them the link stage fails. This is normally handled by prefixing your shared libs with '-Bdynamic'. Unfortunately there is no way to tell premake5 that an external link lib is static or dynamic, so you have to manually fixup the make files, which defeats the purpose of a build utility.

This is kind of a showstopper. I don't think you can just feed "-Bdynamic" into the linkoptions because it must be followed by the list of shared libraries.


Solution

  • Seems like a bug in gmake action (or at least a missing functionality) For those, the best approach is to go to the Premake page on Github (https://github.com/premake/premake-core) and create a new issue.

    And if you have the time to provide a small reproductible project (a static lib project, a dynamic one, and an application using both, each with only 1 cpp or some simple stuff + the premake script) and attach it to the issue, it would also be really appreciated (and much easier to treat this issue ^^)