Skip to content
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

Regarding the issue of static compilation not taking effect #4148

Open
SunnyCaptain opened this issue Aug 19, 2024 · 3 comments
Open

Regarding the issue of static compilation not taking effect #4148

SunnyCaptain opened this issue Aug 19, 2024 · 3 comments
Assignees
Labels
Enhancement Improvement or enhancement.

Comments

@SunnyCaptain
Copy link

I specified the -- static option when configuring, but the compiled SRS program is still dynamically linked. There is no such problem in version 3.0, but upgrading to version 4.0 will cause this issue, which has been bothering me for a long time. I hope the experts can give me some advice!

=======================================================================================

我在configure时指定了--static选项,但是编译得到的srs程序仍然是dynamically linked,在3.0版本没有这个问题,但是升级4.0版本就会这样,困扰了很长时间,望大佬们赐教!

@suzp1984
Copy link
Contributor

If you really need to use a static linked executable, here is the solution:

SrsLinkOptions="${SrsLinkOptions} -static-libstdc++";

change to:
SrsLinkOptions="${SrsLinkOptions} -static";

But I don't think the fully static linked executable is a good idea.
-static-libstdc++ will use static linked libstdc++ to replace the libstdc++.so,
-static-libgcc will remove libgcc_s.so,
With those 2 link options will make your executable portable enough.

@winlinvip
Copy link
Member

winlinvip commented Aug 22, 2024

@suzp1984 I believe it is acceptable to support statically linking libc by modifying the following:

SrsLinkOptions="${SrsLinkOptions} -static-libstdc++ -static"; 

Could you please file a PR to address this?

PS: Previously, we only statically linked libc++, not libc, because most of libc is compatible.

@winlinvip winlinvip self-assigned this Aug 22, 2024
@winlinvip winlinvip added the Enhancement Improvement or enhancement. label Aug 22, 2024
@winlinvip winlinvip linked a pull request Aug 22, 2024 that will close this issue
@winlinvip
Copy link
Member

winlinvip commented Aug 28, 2024

I closed pull request #4152 because the current side effects of using -static are unclear. Despite statically linking glibc, some functions are still dynamically linked, which could potentially cause other issues.

If you are willing to take the risk, you can modify the code yourself by replacing -static-libstdc++ with -static in the configure script.

TRANS_BY_GPT4

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

Successfully merging a pull request may close this issue.

3 participants