Linux can't compile libevent, keeps reporting errors, but I have openssl installed

make, error after executing configure:

make
make  all-recursive
make[1]: Entering directory `/libevent-2.0.21-stable"
Making all in .
make[2]: Entering directory `/libevent-2.0.21-stable"
/bin/bash ./libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.  -I./compat -I./include -I./include    -g -O2 -Wall -fno-strict-aliasing -pthread -MT bufferevent_openssl.lo -MD -MP -MF .deps/bufferevent_openssl.Tpo -c -o bufferevent_openssl.lo bufferevent_openssl.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I./compat -I./include -I./include -g -O2 -Wall -fno-strict-aliasing -pthread -MT bufferevent_openssl.lo -MD -MP -MF .deps/bufferevent_openssl.Tpo -c bufferevent_openssl.c  -fPIC -DPIC -o .libs/bufferevent_openssl.o
bufferevent_openssl.c: In function "bio_bufferevent_new":
bufferevent_openssl.c:106:3: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:107:3: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:108:3: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:109:3: error: dereferencing pointer to incomplete type
bufferevent_openssl.c: In function "bio_bufferevent_free":
bufferevent_openssl.c:119:7: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:120:8: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:120:19: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:121:22: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:122:4: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:123:4: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:124:4: error: dereferencing pointer to incomplete type
bufferevent_openssl.c: In function "bio_bufferevent_read":
bufferevent_openssl.c:140:8: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:143:33: error: dereferencing pointer to incomplete type
bufferevent_openssl.c: In function "bio_bufferevent_write":
bufferevent_openssl.c:159:31: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:165:8: error: dereferencing pointer to incomplete type
bufferevent_openssl.c: In function "bio_bufferevent_ctrl":
bufferevent_openssl.c:191:31: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:196:10: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:199:4: error: dereferencing pointer to incomplete type
bufferevent_openssl.c: At top level:
bufferevent_openssl.c:228:1: error: variable "methods_bufferevent" has initializer but incomplete type
bufferevent_openssl.c:229:2: warning: excess elements in struct initializer [enabled by default]
bufferevent_openssl.c:229:2: warning: (near initialization for "methods_bufferevent") [enabled by default]
bufferevent_openssl.c:229:2: warning: excess elements in struct initializer [enabled by default]
bufferevent_openssl.c:229:2: warning: (near initialization for "methods_bufferevent") [enabled by default]
bufferevent_openssl.c:230:2: warning: excess elements in struct initializer [enabled by default]
bufferevent_openssl.c:230:2: warning: (near initialization for "methods_bufferevent") [enabled by default]
bufferevent_openssl.c:231:2: warning: excess elements in struct initializer [enabled by default]
bufferevent_openssl.c:231:2: warning: (near initialization for "methods_bufferevent") [enabled by default]
bufferevent_openssl.c:232:2: warning: excess elements in struct initializer [enabled by default]
bufferevent_openssl.c:232:2: warning: (near initialization for "methods_bufferevent") [enabled by default]
bufferevent_openssl.c:233:2: warning: excess elements in struct initializer [enabled by default]
bufferevent_openssl.c:233:2: warning: (near initialization for "methods_bufferevent") [enabled by default]
bufferevent_openssl.c:234:2: warning: excess elements in struct initializer [enabled by default]
bufferevent_openssl.c:234:2: warning: (near initialization for "methods_bufferevent") [enabled by default]
bufferevent_openssl.c:235:2: warning: excess elements in struct initializer [enabled by default]
bufferevent_openssl.c:235:2: warning: (near initialization for "methods_bufferevent") [enabled by default]
bufferevent_openssl.c:236:2: warning: excess elements in struct initializer [enabled by default]
bufferevent_openssl.c:236:2: warning: (near initialization for "methods_bufferevent") [enabled by default]
bufferevent_openssl.c:237:2: warning: excess elements in struct initializer [enabled by default]
bufferevent_openssl.c:237:2: warning: (near initialization for "methods_bufferevent") [enabled by default]
bufferevent_openssl.c: In function "BIO_new_bufferevent":
bufferevent_openssl.c:257:8: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:258:8: error: dereferencing pointer to incomplete type
bufferevent_openssl.c:259:8: error: dereferencing pointer to incomplete type

View the 106line file, which is BIO * h

static int
bio_bufferevent_new(BIO *b)
{
    b->init = 0;
    b->num = -1;
    b->ptr = NULL; /* We"ll be putting the bufferevent in this field.*/
    b->flags = 0;
    return 1;
}

but bio.h exists when performing ls, discovery under my / usr/include/openssl directory

execute openssl version-a:

OpenSSL 1.1.0g  2 Nov 2017
built on: reproducible build, date unspecified
platform: dist
compiler: cc -DNDEBUG -DOPENSSL_NO_DYNAMIC_ENGINE -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/usr/local/lib/engines-1.1\"" 
OPENSSLDIR: "/usr/local/ssl"
ENGINESDIR: "/usr/local/lib/engines-1.1"

I don"t know what"s going on right now.
the compilation environment is linux,. Give me a hint, how to check the problem?


this is caused by incompatibility between libevent and openssl versions.

generally speaking, their version relationship is like this

< table > < thead > < tr > < th > libevent < / th > < th > openssl < / th > < / tr > < / thead > < tbody > < tr > < td > 2.1.x < / td > < td > 1.1 < / td > < / tr > < tr > < td > 2.0.x < / td > < td > 1.0 < / td > < / tr > < / tbody > < / table >

so you have two choices

  1. uses version 2.1.x of libevent, which matches your native openssl 1.1 and can be compiled without any modification.
  2. using version 2.0.x of libevent, you need to install version 1.0 of openssl and then specify the linked version at compile time.
< hr >

the second option is described in detail below, which is universal and suitable for version incompatibility problems when compiling other software.

  1. install openssl version 1.0 first, and note that header files are required. You can choose to install from the source code, or use the operating system's repository to download the installation.
    this type of installation package usually has the word "*-dev", for example, the centos distribution may be like this

    yum install openssl-devel-1.0xxx
  2. After

    openssl is installed, there will be a pkgconfig/ directory. The actual path depends on what you did in the previous step, which is usually located under / usr/lib or / usr/local/lib .
    here we assume that it is / usr/local/lib/openssl-1.0/pkgconfig/ , which you need to set to the environment variable value of PKG_CONFIG_PATH , such as

    export PKG_CONFIG_PATH=/usr/local/lib/openssl-1.0/pkgconfig/ 
  3. switch to the libevent source directory, and add configure configuration variables, such as

    , to the path of the openssl header file and the path to the library file.
    ./configure   CFLAGS="$(pkg-config --cflags openssl)"   LDFLAGS="$(pkg-config --libs openssl)"
  4. clear the original content and recompile

    make clean
    make -j8
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b362bd-2c008.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b362bd-2c008.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?