<tfoot id='rCfNe'></tfoot>
    • <bdo id='rCfNe'></bdo><ul id='rCfNe'></ul>

  • <i id='rCfNe'><tr id='rCfNe'><dt id='rCfNe'><q id='rCfNe'><span id='rCfNe'><b id='rCfNe'><form id='rCfNe'><ins id='rCfNe'></ins><ul id='rCfNe'></ul><sub id='rCfNe'></sub></form><legend id='rCfNe'></legend><bdo id='rCfNe'><pre id='rCfNe'><center id='rCfNe'></center></pre></bdo></b><th id='rCfNe'></th></span></q></dt></tr></i><div id='rCfNe'><tfoot id='rCfNe'></tfoot><dl id='rCfNe'><fieldset id='rCfNe'></fieldset></dl></div>

    <small id='rCfNe'></small><noframes id='rCfNe'>

    1. <legend id='rCfNe'><style id='rCfNe'><dir id='rCfNe'><q id='rCfNe'></q></dir></style></legend>

        如何在 C/C++ 中使用静态链接与 OpenSSL

        How to use static linking with OpenSSL in C/C++(如何在 C/C++ 中使用静态链接与 OpenSSL)

        <small id='SA7Le'></small><noframes id='SA7Le'>

      1. <legend id='SA7Le'><style id='SA7Le'><dir id='SA7Le'><q id='SA7Le'></q></dir></style></legend>

                <tfoot id='SA7Le'></tfoot>
              • <i id='SA7Le'><tr id='SA7Le'><dt id='SA7Le'><q id='SA7Le'><span id='SA7Le'><b id='SA7Le'><form id='SA7Le'><ins id='SA7Le'></ins><ul id='SA7Le'></ul><sub id='SA7Le'></sub></form><legend id='SA7Le'></legend><bdo id='SA7Le'><pre id='SA7Le'><center id='SA7Le'></center></pre></bdo></b><th id='SA7Le'></th></span></q></dt></tr></i><div id='SA7Le'><tfoot id='SA7Le'></tfoot><dl id='SA7Le'><fieldset id='SA7Le'></fieldset></dl></div>
                  <bdo id='SA7Le'></bdo><ul id='SA7Le'></ul>

                    <tbody id='SA7Le'></tbody>

                • 本文介绍了如何在 C/C++ 中使用静态链接与 OpenSSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我用 Openssl 用 C 和 C++ 编写了简单的应用程序.我是这样编译的:

                  I wrote simple apps with Openssl in C and C++. I compile them like this:

                  gcc openssltest.c -o openssltest -lcrypto
                  g++ openssltest.cpp -o openssltest -lcrypto
                  

                  一切正常,但前提是你安装了 Openssl.

                  And its all ok but only, when you have Openssl installed.

                  我想编译它,以便我可以在没有 Openssl installend(类似 linux 的操作系统)的操作系统上运行它们.我试过这个:

                  I would like to compile it that I can run them on OS where theres no Openssl installend (linux-like OS). I tried this:

                  gcc -c openssltest.c -lcrypto -static
                  gcc openssltest.o -o openssltest -lcrypto -static
                  

                  和 C++ 一样:

                  g++ -c openssltest.cpp -lcrypto -static
                  g++ openssltest.o -o openssltest -lcrypto -static
                  

                  但是有这些错误:

                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
                  (.text+0x19): undefined reference to `dlopen'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
                  (.text+0x2c): undefined reference to `dlsym'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
                  (.text+0x37): undefined reference to `dlclose'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
                  (.text+0x354): undefined reference to `dlsym'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
                  (.text+0x3fb): undefined reference to `dlerror'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
                  (.text+0x474): undefined reference to `dlsym'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
                  (.text+0x52e): undefined reference to `dlerror'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
                  (.text+0x5a2): undefined reference to `dlopen'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
                  (.text+0x60b): undefined reference to `dlclose'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
                  (.text+0x638): undefined reference to `dlerror'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
                  (.text+0x6cd): undefined reference to `dladdr'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
                  (.text+0x731): undefined reference to `dlerror'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
                  (.text+0x78a): undefined reference to `dlclose'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
                  (.text+0x4d): undefined reference to `inflateEnd'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
                  (.text+0x6b): undefined reference to `deflateEnd'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
                  (.text+0x284): undefined reference to `deflate'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
                  (.text+0x342): undefined reference to `zError'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_expand_block':
                  (.text+0x411): undefined reference to `inflate'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_compress_block':
                  (.text+0x4ca): undefined reference to `deflate'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
                  (.text+0x51f): undefined reference to `inflateEnd'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
                  (.text+0x528): undefined reference to `deflateEnd'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
                  (.text+0x5d7): undefined reference to `inflateInit_'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
                  (.text+0x659): undefined reference to `deflateInit_'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
                  (.text+0x893): undefined reference to `inflate'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
                  (.text+0x90d): undefined reference to `zError'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
                  (.text+0x97c): undefined reference to `inflateInit_'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
                  (.text+0xa6f): undefined reference to `deflate'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
                  (.text+0xaec): undefined reference to `zError'
                  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
                  (.text+0xb7e): undefined reference to `deflateInit_'
                  collect2: error: ld returned 1 exit status
                  

                  我怎样才能做到这一点?我记得不久前我做了这个,但现在,呃,忘记了怎么做.我使用的是 Ubuntu 13.04 x64 - 会不会有问题?

                  How can I make this? I remember that a while ago I did this but now, erm, forgot how to do it. Im on Ubuntu 13.04 x64 - can it be an issue?

                  推荐答案

                  我在尝试使用 openssl 库静态编译一个简单的 DES 程序时遇到了类似的问题.我使用了 -lcrypto -lz -ldl -static-libgcc 并且它对我有用.没有警告或错误.

                  I had a similar issue trying to statically compile a simple DES program using the openssl lib. I used -lcrypto -lz -ldl -static-libgcc and it worked for me. No warnings or errors.

                  这篇关于如何在 C/C++ 中使用静态链接与 OpenSSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C++ stl unordered_map implementation, reference validity(C++ stl unordered_map 实现,参考有效性)
                  C++: Is it possible to use a reference as the value in a map?(C++:是否可以使用引用作为映射中的值?)
                  Where ampersand quot;amp;quot; can be put when passing argument by reference?(其中符号“amp;通过引用传递参数时可以放置吗?)
                  Why can a non-const reference parameter be bound to a temporary object?(为什么可以将非常量引用参数绑定到临时对象?)
                  What is a dangling reference?(什么是悬空引用?)
                  C++ reference changes when push_back new element to std::vector(当 push_back 新元素到 std::vector 时,C++ 引用发生变化)

                • <small id='DbnfN'></small><noframes id='DbnfN'>

                  <tfoot id='DbnfN'></tfoot>
                • <i id='DbnfN'><tr id='DbnfN'><dt id='DbnfN'><q id='DbnfN'><span id='DbnfN'><b id='DbnfN'><form id='DbnfN'><ins id='DbnfN'></ins><ul id='DbnfN'></ul><sub id='DbnfN'></sub></form><legend id='DbnfN'></legend><bdo id='DbnfN'><pre id='DbnfN'><center id='DbnfN'></center></pre></bdo></b><th id='DbnfN'></th></span></q></dt></tr></i><div id='DbnfN'><tfoot id='DbnfN'></tfoot><dl id='DbnfN'><fieldset id='DbnfN'></fieldset></dl></div>
                    <tbody id='DbnfN'></tbody>

                      • <bdo id='DbnfN'></bdo><ul id='DbnfN'></ul>

                        <legend id='DbnfN'><style id='DbnfN'><dir id='DbnfN'><q id='DbnfN'></q></dir></style></legend>