Skip to content

Readd shared library module compilation docs#11820

Closed
dementive wants to merge 1 commit intogodotengine:masterfrom
dementive:shared-library-module-compilation
Closed

Readd shared library module compilation docs#11820
dementive wants to merge 1 commit intogodotengine:masterfrom
dementive:shared-library-module-compilation

Conversation

@dementive
Copy link
Copy Markdown
Contributor

Adds back the shared library custom module compilation documentation that was removed in 160aa37 and adds the missing parts that were making it not work.

The original documentation was flawed because it was missing the -rdynamic flag (see: https://stackoverflow.com/a/24016413) but with it compiling as a shared library works as expected. I have been using this for about a year and a half now and it has continued to work the same without any problems.

For me this is a core part of my workflow as it brings my compile times down to 0.5-2 seconds depending on the file but without it compiles take around 8-10 seconds because of the time it takes to link the full binary for every build. Would be great to have this documentation back up because hopefully someone smarter than me will see it in the future and work out how to get this to work on Windows too if that is even possible.

@dementive dementive requested review from a team as code owners March 5, 2026 03:29
@AThousandShips AThousandShips requested a review from Calinou March 5, 2026 09:25
and as a shared library when passing ``summator_shared=yes``.

Finally, you can even speed up the build further by explicitly specifying your
shared module as target in the SCons command:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
shared module as target in the SCons command:
shared module as the target in the SCons command:

# Static compilation
module_env.add_source_files(env.modules_sources, sources)

Now by default ``scons`` command will build our module as part of Godot's binary
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Now by default ``scons`` command will build our module as part of Godot's binary
Now by default the ``scons`` command will build our module as part of Godot's binary

./bin/godot*

.. note::
You have to ``export`` the environment variable. Otherwise,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You have to ``export`` the environment variable. Otherwise,
You have to ``export`` the environment variable. Otherwise,



On top of that, it would be nice to be able to select whether to compile our
module as shared library (for development) or as a part of the Godot binary
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
module as shared library (for development) or as a part of the Godot binary
module as a shared library (for development) or as a part of the Godot binary


# LIBPATH and LIBS need to be set on the real "env" (not the clone)
# to link the specified libraries to the Godot executable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change


env.Append(LIBPATH=['#bin'])

# SCons wants the name of the library with it custom suffixes
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# SCons wants the name of the library with it custom suffixes
# SCons wants the name of the library with its custom suffixes

@Calinou Calinou added enhancement area:engine details Issues and PRs related to the Engine Details section of the documentation topic:buildsystem labels Mar 16, 2026
# Don't inject Godot's dependencies into our shared library.
module_env['LIBS'] = []

# Required for symbols from godot to link when rebuilding shared library.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Required for symbols from godot to link when rebuilding shared library.
# Required for symbols from Godot to link when rebuilding shared library.

Comment on lines +453 to +458


Once compiled, we should end up with a ``bin`` directory containing both the
``godot*`` binary and our ``libsummator*.so``. However given the .so is not in
a standard directory (like ``/usr/lib``), we have to help our binary find it
during runtime with the ``LD_LIBRARY_PATH`` environment variable:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extraneous blank line:

Suggested change
Once compiled, we should end up with a ``bin`` directory containing both the
``godot*`` binary and our ``libsummator*.so``. However given the .so is not in
a standard directory (like ``/usr/lib``), we have to help our binary find it
during runtime with the ``LD_LIBRARY_PATH`` environment variable:
Once compiled, we should end up with a ``bin`` directory containing both the
``godot*`` binary and our ``libsummator*.so``. However given the .so is not in
a standard directory (like ``/usr/lib``), we have to help our binary find it
during runtime with the ``LD_LIBRARY_PATH`` environment variable:

Comment on lines +468 to +470


On top of that, it would be nice to be able to select whether to compile our
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extraneous blank line:

Suggested change
On top of that, it would be nice to be able to select whether to compile our
On top of that, it would be nice to be able to select whether to compile our

Copy link
Copy Markdown
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good to merge after applying suggestions.

@skyace65
Copy link
Copy Markdown
Contributor

Closing this due to the lack of a response to reviews for over a month. If the original author wishes to update this please do so and @ me to re-open this PR. If another maintainer wishes to salvage this PR with another one, or commit to the branch, feel free to. I personally am not doing so due to my limited C++ experience, I wouldn't be able to update or maintain this in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

archived area:engine details Issues and PRs related to the Engine Details section of the documentation enhancement topic:buildsystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants