Openssllibcrypto. a and libssl. a solve the problem of undefined reference to error when referencing openssl static libraries libcrypto..

Source: Internet
Author: User
Tags openssl library

Openssllibcrypto. a and libssl. a solve the problem of undefined reference to error when referencing openssl static libraries libcrypto..

Recently, the project that uses openssl to link http and https has encountered the following problems during compilation.

/Usr/local/openssl/lib/libcrypto. a (async. o): In function 'async _ free_pool_internal ':
Async. c :(. text + 0xe4): undefined reference to 'pthread _ setspecific'
Async. c :(. text + 0xf4): undefined reference to 'pthread _ getspecific'
Async. c :(. text + 0x104): undefined reference to 'pthread _ setspecific'
/Usr/local/openssl/lib/libcrypto. a (async. o): In function 'async _ init_thread.part.1 ':
Async. c :(. text + 0x253): undefined reference to 'pthread _ setspecific'
/Usr/local/openssl/lib/libcrypto. a (async. o): In function 'async _ start_func ':
Async. c :(. text + 0x36f): undefined reference to 'pthread _ getspecific'
Async. c :(. text + 0x39e): undefined reference to 'pthread _ getspecific'
/Usr/local/openssl/lib/libcrypto. a (async. o): In function 'async _ start_job ':
Async. c :(. text + 0x404): undefined reference to 'pthread _ getspecific'
Async. c :(. text + 0x41e): undefined reference to 'pthread _ getspecific'
Async. c :(. text + 0x433): undefined reference to 'pthread _ getspecific'
/Usr/local/openssl/lib/libcrypto. a (async. o): async. c :(. text + 0x44c): more undefined references to 'pthread _ getspecific 'follow
/Usr/local/openssl/lib/libcrypto. a (async. o): In function 'async _ start_job ':
Async. c :(. text + 0x7ef): undefined reference to 'pthread _ setspecific'
Async. c :(. text + 0x811): undefined reference to 'pthread _ getspecific'
Async. c :(. text + 0x82d): undefined reference to 'pthread _ getspecific'
Async. c :(. text + 0x83f): undefined reference to 'pthread _ getspecific'
Async. c :(. text + 0x870): undefined reference to 'pthread _ getspecific'
Async. c :(. text + 0x891): undefined reference to 'pthread _ getspecific'
/Usr/local/openssl/lib/libcrypto. a (async. o): async. c :(. text + 0x8a6): more undefined references to 'pthread _ getspecific 'follow
/Usr/local/openssl/lib/libcrypto. a (async_posix.o): In function 'async _ global_init ':
Async_posix.c :(. text + 0xc): undefined reference to 'pthread _ key_create'
Async_posix.c :(. text + 0x1e): undefined reference to 'pthread _ key_create'
/Usr/local/openssl/lib/libcrypto. a (async_posix.o): In function 'async _ local_init ':
Async_posix.c :(. text + 0x3d): undefined reference to 'pthread _ setspecific'
Async_posix.c :(. text + 0x50): undefined reference to 'pthread _ setspecific'
/Usr/local/openssl/lib/libcrypto. a (dso_dlfcn.o): In function 'dlfcn _ globallookup ':
Dso_dlfcn.c :(. text + 0x21): undefined reference to 'dlopen'
Dso_dlfcn.c :(. text + 0x34): undefined reference to 'dlsym'
Dso_dlfcn.c :(. text + 0x3f): undefined reference to 'dlclose'
/Usr/local/openssl/lib/libcrypto. a (dso_dlfcn.o): In function 'dlfcn _ bind_func ':
Dso_dlfcn.c :(. text + 0x354): undefined reference to 'dlsym'
Dso_dlfcn.c :(. text + 0x3fb): undefined reference to 'dlerror'
/Usr/local/openssl/lib/libcrypto. a (dso_dlfcn.o): In function 'dlfcn _ bind_var ':
Dso_dlfcn.c :(. text + 0x474): undefined reference to 'dlsym'
Dso_dlfcn.c :(. text + 0x52e): undefined reference to 'dlerror'
/Usr/local/openssl/lib/libcrypto. a (dso_dlfcn.o): In function 'dlfcn _ load ':
Dso_dlfcn.c :(. text + 0x5a4): undefined reference to 'dlopen'
Dso_dlfcn.c :(. text + 0x60b): undefined reference to 'dlclose'
Dso_dlfcn.c :(. text + 0x638): undefined reference to 'dlerror'
/Usr/local/openssl/lib/libcrypto. a (dso_dlfcn.o): In function 'dlfcn _ pathbyaddr ':
Dso_dlfcn.c :(. text + 0x6ce): undefined reference to 'dladd'
Dso_dlfcn.c :(. text + 0x731): undefined reference to 'dlerror'
/Usr/local/openssl/lib/libcrypto. a (dso_dlfcn.o): In function 'dlfcn _ unload ':
Dso_dlfcn.c :(. text + 0x78a): undefined reference to 'dlclose'

 

Solution:

Gcc obj/Debug/main. o-L/usr/local/openssl/lib-lssl-lcrypto-ldl-lpthread-o main

Cause analysis:

When linking this database, you must pay attention to two issues:

1. For openssl library version problems, please link directly to the openssl library path you need. For example, my files are/usr/local/openssl/lib,

2. Note that-lssl-lcrypto must be written before-ldl-lpthread.

Related Knowledge:

-L: This option specifies the folder address of the Linked Library.

-L (lower-case L):-lssl is the library libssl. a under the/usr/local/openssl/lib directory. The Compiler automatically searches for libssl. a or libssl. so.

-I (uppercase I): Specifies the folder address of the header file.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.