-
Notifications
You must be signed in to change notification settings - Fork 13
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
udphop 如何静态编译"-static" #3
Comments
这是GNU链接工具的锅,就连Botan作者都无法解决。 反倒是FreeBSD(用clang)和Windows(用MSVC)都可以正常使用静态链接的版本。 如果需要在Linux(以及NetBSD)使用静态链接,需要按照 https://botan.randombit.net/handbook/building.html 的 The Amalgamation Build 小节的介绍,制作出巨大无比的 botan_all.h 和botan_all.cpp 直接内嵌到项目中。 第一步:
第二步:把生成好的两个 botan_all 复制到 udphop/src/shares 第三步:修改 udphop/src/shares/CMakeLists.txt,找到
修改为
第四步:打开 udphop/src/shares/aead.hpp,把那一大串 第五步:打开 udphop/CMakeLists.txt,把Linux那一行的 这样就可以静态编译了。只是编译出来的二进制十分巨大,比FreeBSD的和Windows的都大得多。 |
十分巨大 是不是可以 strip --strip-debug 或者直接strip 再加upx打包 我这边自己尝试了一下,编译好动态的加载的udphop,把动态依赖库全部复制到当前目录,然后用patchelf修改成加载为当前路径的库
感谢作者解答 |
已经成功编译静态链接的udphop: 1.一定要用 botan-2x的源码 grep -r 'target_link_libraries' ./ On Modern CMake (3.x+ - target_link_libraries doc), you can apply the flag to specific targets, in this way: #original #strip #upx |
在 alpine 中静态编译会报
The text was updated successfully, but these errors were encountered: