8000 td doesn't install shared libraries despite configuring with TD_INSTALL_SHARED_LIBRARIES=ON · Issue #3325 · tdlib/td · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

td doesn't install shared libraries despite configuring with TD_INSTALL_SHARED_LIBRARIES=ON #3325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
yurivict opened this issue May 9, 2025 · 6 comments

Comments

@yurivict
Copy link
8000
yurivict commented May 9, 2025

It only installs static libs, with one exception of libtdjson:

lib/libtdactor.a
lib/libtdapi.a
lib/libtdclient.a
lib/libtdcore.a
lib/libtddb.a
lib/libtde2e.a
lib/libtdjson.so
lib/libtdjson_private.a
lib/libtdjson_static.a
lib/libtdmtproto.a
lib/libtdnet.a
lib/libtdsqlite.a
lib/libtdutils.a

Version: 1.8.48 (hash b8b08b0)
FreeBSD 14.2

@levlam
Copy link
Contributor
levlam commented May 9, 2025

libtdjson is the only library that is supposed to be shared. The options TD_INSTALL_STATIC_LIBRARIES and TD_INSTALL_SHARED_LIBRARIES can be used to avoid installation of static or shared libraries. See #3081 for the history, why the options were introduced.

@yurivict
Copy link
Author
yurivict commented May 9, 2025

The linked issue says that static libs are built for the sake of projects that embed tdlib.

But on FreeBSD in the ports we avoid static libs because port/package dependencies are hard to track when they install static libs.

Is there a way to add a non-default option to always build all shared libs?

@tdlib tdlib deleted a comment May 10, 2025
@tdlib tdlib deleted a comment May 10, 2025
@tdlib tdlib deleted a comment May 10, 2025
@tdlib tdlib deleted a comment May 10, 2025
@yurivict
Copy link
Author

Removing the STATIC keywords from all add_library instructions and making BUILD_SHARED_LIBS to depend on the option TD_INSTALL_SHARED_LIBRARIES does the trick.

@levlam
Copy link
Contributor
levlam commented May 11, 2025

Yes. You don't even need to make BUILD_SHARED_LIBS dependent on TD_INSTALL_SHARED_LIBRARIES. Just specify BUILD_SHARED_LIBS separately during cmake configuration. The option is supposed to be provided by the user of cmake, not by the CMakeLists.txt itself.

This works only because GCC/clang export everything from shared libraries by default, which significantly increase binary size, can expose some internal functions and data, and have no chance to work on Windows. In the case of TDLib having the libraries as shared libraries provides no advantages given that they don't have stable interface and can't be updated independently.

But if installing of shared libraries only is a required policy and can't be avoided, then I can only point to https://lore.kernel.org/lkml/CAHk-=whs8QZf3YnifdLv57+FhBi5_WeNTG1B-suOES=RcUSmQg@mail.gmail.com/ and propose to patch all CMakeLists.txt files and remove 'STATIC' from all library definitions on the package manager side.

@yurivict
Copy link
Author

Just specify BUILD_SHARED_LIBS separately during cmake configuration.

This doesn't work because every add_library instruction has the STATIC argument hardcoded.

@levlam
Copy link
Contributor
levlam commented May 12, 2025

You said

Removing the STATIC keywords from all add_library instructions and making BUILD_SHARED_LIBS to depend on the option TD_INSTALL_SHARED_LIBRARIES does the trick.

I commented that the second part isn't needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@yurivict @levlam and others
0