question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] bazel generator not usable for packages with multiple libs, like openssl

See original GitHub issue

Environment Details

  • Operating System+version: All
  • Compiler+version: Not relevant
  • Conan version: All
  • Python version: All

Steps to reproduce

Use the bazel generator and use libcurl on Linux in your project, so it depends on openssl. libcurl will not be usable in your bazel project, since libcrypto.a and libssl.a appear in the wrong order for the linker

Solution

To make the order work, the alwayslink = True attribute should be set on the cc_import libs

So this:

cc_import(
    name = "ssl_precompiled",
    static_library = "lib/libssl.a",
)

cc_import(
    name = "crypto_precompiled",
    static_library = "lib/libcrypto.a",
)

should look like that

cc_import(
    name = "ssl_precompiled",
    static_library = "lib/libssl.a",
    alwayslink = True,
)

cc_import(
    name = "crypto_precompiled",
    static_library = "lib/libcrypto.a",
    alwayslink = True,
)

in the generated BUILD file for openssl

we can also discuss if it would not make sense to set visibility = ["//visibility:public"], on the cc_import part, since there are use cases where users use only libcrypto , but not libssl from openssl, but that might be a different issue

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
czoidocommented, Jul 1, 2022

yes, the #do not sort on the right position does prevent buildifier from sorting array entries I updated the PR

Great, I’ll mark this for the next release. Thanks for the contribution.

0reactions
a4zcommented, Jul 1, 2022

yes, the #do not sort on the right position does prevent buildifier from sorting array entries I updated the PR

Read more comments on GitHub >

github_iconTop Results From Across the Web

C++ how to static link to openssl using bazel - Stack Overflow
but the openssl version of deploy machine is not the same with my compile machine, so I want to link staticlly to openssl...
Read more >
When to use Bazel? - Hacker News
it's pretty trivial to create static binaries in Rust, but things like openssl won't compile since openssl depends on glibc. Two commands to...
Read more >
Conan Documentation
Conan is a software package manager which is intended for C and C++ developers. Conan is universal and portable. It works in all...
Read more >
A list of open source C++ libraries - cppreference.com
There are no restrictions on what can be included except that the source of the library must be readily available to download. The...
Read more >
Getting Started With The POCO C++ Libraries
However, these packages are not maintained by the core team and may not always be up ... For multi-configuration generators, (like Visual Studio...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found