<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><b style="font-size:large"> Hi:</b><br></div><div dir="ltr"><font size="4"><b>I static compile opensslv1.1.1 on Ubuntu18.04 as follow :</b></font><div>  $./config no-shared</div><div><font size="4"><b>and then:</b></font></div><div>  $make </div><div>  $make install</div><div><font size="4"><b>after that, I write a test.c like this:</b></font></div><div><br></div><div>#include <stdio.h><br>#include <string.h><br>#include <time.h><br>#include <openssl/err.h><br>#include <openssl/bn.h><br>#include <openssl/rsa.h><br>#include <openssl/pem.h><br>#include <openssl/crypto.h><br>#include <ctype.h><br>#include <stdlib.h><br>#include <unistd.h><br><br>int generate_key(int bits, int count)<br>{<br>    int             ret = 0;<br>    RSA             *r = NULL;<br>    BIGNUM          *bne = NULL; <br>    unsigned long   e = RSA_F4;<br><br><br>    fprintf(stdout, "id;n;e;p;q;d;t\n");<br><br>    for (int i = 0; i < count; i++) {<br>        bne = BN_new();<br>        ret = BN_set_word(bne,e);<br><br><br>        r = RSA_new();<br>        ret = RSA_generate_key_ex(r, bits, bne, NULL);<br>    }   <br><br>    return (ret == 1);<br>}<br><br>// added main function<br>int main (){<br>    printf("Hello\n");<br>    return 0;<br>}<br></div><div><b><br></b></div><div><font size="4"><b>and static compile it as follow:</b></font></div><div>  $gcc -static -o test test.c -lssl -lcrypto -ldl -pthread</div><div>   x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':<br>   dso_dlfcn.c:(.text+0x11): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking<br>   libcrypto.a(b_addr.o): In function `BIO_lookup_ex':<br>b_addr.c:(.text+0xcea): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking<br>   x86_64-linux-gnu/libcrypto.a(b_sock.o): In function `BIO_gethostbyname':<br>   b_sock.c:(.text+0x71): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking<br></div><div><b><font size="4">when i exec the test:</font></b></div><div>  $./test</div><div>  [1]    36025 segmentation fault (core dumped)  ./test</div><div><br></div><div><font size="4"><b>Use gdb for debug:</b></font></div><div> gdb-peda$ bt<br> #0  0x0000000000000000 in ?? ()<br> #1  0x00000000005a14e5 in __register_frame_info_bases.part.6 ()<br> #2  0x000000000040168d in frame_dummy ()<br> #3  0x0000000000000001 in ?? ()<br> #4  0x00000000005a275c in __libc_csu_init ()<br> #5  0x00000000005a1f27 in __libc_start_main ()<br> #6  0x00000000004015aa in _start () <br></div><div>  </div><div><font size="4"><b>So, how did i use openssl for static link?</b></font><br clear="all"><div><br></div></div></div></div></div>