config& amp;生成的openssl二进制文件从源代码构建时,make命令会动态链接到这些库:
linux-vdso.so.1 => (0x00007fffa75fe000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff7f79ab000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff7f75e2000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff7f7bd2000)
我的猜测是,如果我可以静态链接到lib gcc,其他共享库的依赖关系也会消失。
问题是如何让Configure脚本生成静态链接的二进制文件?
在Windows上构建过程是否也一样?
答案 0 :(得分:1)
我在搜索同样的内容时遇到过这篇文章。我不知道使用configure脚本执行此操作的正确语法,但这就是我实现它的方法。
cd /tmp
wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz
tar -zxvf openssl-1.0.1e.tar.gz
cd openssl-1.0.1e
./config
然后我将“-static -static-libgcc”添加到openssl-1.0.1e / Makefile的CFLAG行中(注意这是在我运行./config之后)。然后我像平常一样建造它。
make INSTALL_PREFIX=/tmp/package-root install
现在已经静态编译了
$ ldd /tmp/package-root/usr/local/ssl/bin/openssl
not a dynamic executable
答案 1 :(得分:1)
我无法使上述解决方案起作用。链接器引发了关于_dlopen未定义的错误。
我在配置行中添加了no-shared选项,这个构建的openssl静态链接到openssl库。
它依赖于libsocket.so.2,linnsl.so,libz.so和libc.so.1
答案 2 :(得分:1)
获取源。我使用git是因为我发现它更容易,但是下载源tar.gz也可以:
objc[517]: Class AKRhodesPianoAudioUnit is implemented in both /private/var/containers/Bundle/Application/5A294050-2DB2-45C9-BB0A-3A0DE25E87C6/Tuner.app/Frameworks/AudioKitUI.framework/AudioKitUI (0x1058413f0) and /var/containers/Bundle/Application/5A294050-2DB2-45C9-BB0A-3A0DE25E87C6/Tuner.app/Tuner (0x104e177e8). One of the two will be used. Which one is undefined.
检查远程分支($ git clone git://git.openssl.org/openssl.git
Cloning into 'openssl'...
remote: warning: unable to access '/root/.config/git/attributes': Permission denied
remote: Counting objects: 318375, done.
remote: Compressing objects: 100% (89565/89565), done.
remote: Total 318375 (delta 227244), reused 309362 (delta 219401)
Receiving objects: 100% (318375/318375), 65.83 MiB | 714.00 KiB/s, done.
Resolving deltas: 100% (227244/227244), done.
)或标签(git branch -r
),然后选择要构建的版本。我使用了最新的1.1.1a:
git tag
使用$ cd openssl
$ git checkout OpenSSL_1_1_1a
Note: checking out 'OpenSSL_1_1_1a'.
...
HEAD is now at d1c28d791a... Prepare for 1.1.1a release
参数运行./config
。
-static
我从INSTALL
文件中得到了这个$ ./config -static
Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1a (0x1010101fL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile
**********************************************************************
*** ***
*** OpenSSL has been successfully configured ***
*** ***
*** If you encounter a problem while building, please open an ***
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
*** and include the output from the following command: ***
*** ***
*** perl configdata.pm --dump ***
*** ***
*** (If you are new to OpenSSL, you might want to consult the ***
*** 'Troubleshooting' section in the INSTALL file first) ***
*** ***
**********************************************************************
参数:
-static
编译:
-Dxxx, -Ixxx, -Wp, -lxxx, -Lxxx, -Wl, -rpath, -R, -framework, -static
These system specific options will be recognised and
passed through to the compiler to allow you to define
preprocessor symbols, specify additional libraries, library
directories or other compiler options. It might be worth
noting that some compilers generate code specifically for
processor the compiler currently executes on. This is not
necessarily what you might have in mind, since it might be
unsuitable for execution on other, typically older,
processor. Consult your compiler documentation.
检查它是否是静态二进制文件:
$ make -j`nproc`
...
无需手动编辑Makefile。 不幸的是,我不知道如何在Windows上做到这一点。
答案 3 :(得分:1)
对于Windows,我成功使用了此顺序
perl Configure VC-WIN32 /MT
nmake
nmake test
nmake install
然后将链接库libcrypto_static.lib,libssl_static.lib链接到您的程序,这些程序也必须使用/ MT编译(调试时使用/ MTd)。
其他Visual Studio编译器版本应具有相同的功能。
注意:根据使用情况,可能需要从生成文件中删除标志-D“ OPENSSL_USE_APPLINK”,并重新编译静态库。
答案 4 :(得分:0)
对我有用的是将class ApiApplicationHandler(RequestHandler):
def get(self, resource, action_id=None):
pass
和 -static
传递到--static
步骤。 ./config
似乎已安装在文档中,但导致构建失败。 --no-shared
本身也导致构建失败。
-static