Skip to content

请教大牛,是否遇到过类似问题:Nginx编译时,Nginx编译不通过,缺少头文件 #5

Description

@Confusedr

编译Nginx时,会报缺少头文件,导致Nginx无法编译通过
Nginx版本为1.24
./configure --with-http_ssl_module --with-debug --without-http_rewrite_module --with-openssl=/usr/local/gmssl-3.1.1 --prefix=/usr/local/nginx

make

make -f objs/Makefile
make[1]: Entering directory '/root/workspace/nginx/nginx'
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I src/lic -I /usr/local/gmssl-3.1.1/include -I objs
-o objs/src/core/nginx.o
src/core/nginx.c
In file included from src/core/ngx_core.h:84,
from src/core/nginx.c:9:
src/event/ngx_event_openssl.h:17:10: fatal error: openssl/des.h: No such file or directory
17 | #include <openssl/des.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [objs/Makefile:380: objs/src/core/nginx.o] Error 1
make[1]: Leaving directory '/root/workspace/nginx/nginx'
make: *** [Makefile:10: build] Error 2

Activity

  1. PikaByter commented on Jun 27, 2024

    @PikaByter

    使用编译方式安装Gmssl,可以避免第一个问题

  2. PikaByter commented on Jun 27, 2024

    @PikaByter

    你检查一下src/event/ngx_event_openssl.h:17:10: fatal error: openssl/des.h: No such file or directory,到底有没有头文件,另外最好po一下make install安装OCL时的日志

  3. changed the title [-]请教大牛,是否遇到过类似问题:OpenSSL-Compatibility-Layer报错需要修改,修改好,编译通过后,引入Nginx编译时,Nginx编译不通过[/-] [+]请教大牛,是否遇到过类似问题:Nginx编译时,Nginx编译不通过,缺少头文件[/+] on Jun 27, 2024
  4. Confusedr commented on Jun 27, 2024

    @Confusedr
    Author

    你检查一下src/event/ngx_event_openssl.h:17:10: fatal error: openssl/des.h: No such file or directory,到底有没有头文件,另外最好po一下make install安装OCL时的日志

    root@debian:/workspace/GmSSL-3.1.1/OpenSSL-Compatibility-Layer-0.8.1/build# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/gmssl3_openssl ..
    -- The C compiler identification is GNU 12.2.0
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: /usr/bin/cc - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /root/workspace/GmSSL-3.1.1/OpenSSL-Compatibility-Layer-0.8.1/build
    root@debian:
    /workspace/GmSSL-3.1.1/OpenSSL-Compatibility-Layer-0.8.1/build# make
    [ 7%] Building C object CMakeFiles/crypto.dir/src/err.c.o
    [ 15%] Building C object CMakeFiles/crypto.dir/src/bio.c.o
    [ 23%] Building C object CMakeFiles/crypto.dir/src/evp.c.o
    /root/workspace/GmSSL-3.1.1/OpenSSL-Compatibility-Layer-0.8.1/src/evp.c: In function ‘EVP_DigestInit_ex’:
    /root/workspace/GmSSL-3.1.1/OpenSSL-Compatibility-Layer-0.8.1/src/evp.c:46:13: warning: implicit declaration of function ‘sm3_digest_init’; did you mean ‘digest_init’? [-Wimplicit-function-declaration]
    46 | if (sm3_digest_init(ctx, NULL, 0) != 1) {
    | ^~~~~~~~~~~~~~~
    | digest_init
    /root/workspace/GmSSL-3.1.1/OpenSSL-Compatibility-Layer-0.8.1/src/evp.c: In function ‘EVP_DigestUpdate’:
    /root/workspace/GmSSL-3.1.1/OpenSSL-Compatibility-Layer-0.8.1/src/evp.c:55:13: warning: implicit declaration of function ‘sm3_digest_update’; did you mean ‘digest_update’? [-Wimplicit-function-declaration]
    55 | if (sm3_digest_update(ctx, d, cnt) != 1) {
    | ^~~~~~~~~~~~~~~~~
    | digest_update
    /root/workspace/GmSSL-3.1.1/OpenSSL-Compatibility-Layer-0.8.1/src/evp.c: In function ‘EVP_DigestFinal_ex’:
    /root/workspace/GmSSL-3.1.1/OpenSSL-Compatibility-Layer-0.8.1/src/evp.c:64:13: warning: implicit declaration of function ‘sm3_digest_finish’; did you mean ‘digest_finish’? [-Wimplicit-function-declaration]
    64 | if (sm3_digest_finish(ctx, dgst) != 1) {
    | ^~~~~~~~~~~~~~~~~
    | digest_finish
    [ 30%] Building C object CMakeFiles/crypto.dir/src/rand.c.o
    [ 38%] Building C object CMakeFiles/crypto.dir/src/asn1.c.o
    [ 46%] Building C object CMakeFiles/crypto.dir/src/x509.c.o
    [ 53%] Building C object CMakeFiles/crypto.dir/src/x509_vfy.c.o
    [ 61%] Building C object CMakeFiles/crypto.dir/src/crypto.c.o
    [ 69%] Building C object CMakeFiles/crypto.dir/src/pem.c.o
    [ 76%] Building C object CMakeFiles/crypto.dir/src/dh.c.o
    [ 84%] Linking C shared library libcrypto.so
    [ 84%] Built target crypto
    [ 92%] Building C object CMakeFiles/ssl.dir/src/ssl.c.o
    [100%] Linking C shared library libssl.so
    [100%] Built target ssl
    root@debian:~/workspace/GmSSL-3.1.1/OpenSSL-Compatibility-Layer-0.8.1/build# make install
    [ 84%] Built target crypto
    [100%] Built target ssl
    Install the project...
    -- Install configuration: ""
    -- Installing: /usr/local/gmssl3_openssl/lib/libcrypto.so
    -- Set runtime path of "/usr/local/gmssl3_openssl/lib/libcrypto.so" to ""
    -- Installing: /usr/local/gmssl3_openssl/lib/libssl.so
    -- Set runtime path of "/usr/local/gmssl3_openssl/lib/libssl.so" to ""
    -- Installing: /usr/local/gmssl3_openssl/include/openssl
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/dh.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/bio.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/hmac.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/opensslv.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/rand.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/x509.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/conf.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/x509_vfy.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/ssl.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/asn1.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/bn.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/x509v3.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/rsa.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/pem.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/err.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/symhacks.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/evp.h
    -- Installing: /usr/local/gmssl3_openssl/include/openssl/crypto.h

    老师好:
    确实没有相关头文件,可以直接拿openssl的相关头文件么?

  5. Confusedr commented on Jun 27, 2024

    @Confusedr
    Author

    使用编译方式安装Gmssl,可以避免第一个问题

    使用master分支编译安装后,解决了

  6. PikaByter commented on Jun 27, 2024

    @PikaByter

    都解决了吗

  7. Confusedr commented on Jun 27, 2024

    @Confusedr
    Author

    都解决了吗
    只有OpenSSL-Compatibility-Layer编译报错的问题解决了,Nginx还在尝试

  8. PikaByter commented on Jun 27, 2024

    @PikaByter

    都解决了吗
    只有OpenSSL-Compatibility-Layer编译报错的问题解决了,Nginx还在尝试

    你看看这个报错和这个类似不:#4
    解决方法是删掉本机的libssl-dev,以免冲突

  9. Confusedr commented on Jun 27, 2024

    @Confusedr
    Author

    都解决了吗
    只有OpenSSL-Compatibility-Layer编译报错的问题解决了,Nginx还在尝试

    你看看这个报错和这个类似不:#4 解决方法是删掉本机的libssl-dev,以免冲突

    非常感谢,缺失的头文件从openssl考过来就可以了,编译已经没有问题了。
    但是现在遇到一个新的问题,希望指点一二,链接时,希望是静态链接,但是OPL标准编译只有动态库,如何能生成静态库?

  10. PikaByter commented on Jun 27, 2024

    @PikaByter

    我之前也遇到过这个问题,然后莫名其妙消失了,好像是config的时候不指定openssl的地址就行?

    你按这个流程试试

    删掉本机的libssl-dev,然后重新编译安装GmSSL和OCL的master版本,再从源码编译安装nginx-1.24.0

    这是我在阿里云一台空白ubuntu22.04机器上从头安装的脚本,你可以参考一下

    #!/bin/bash
    
    apt-get update
    apt-get install cmake git -y
    
    rm -rf GmSSL
    git clone https://github.com/guanzhi/GmSSL.git
    rm -rf OpenSSL-Compatibility-Layer
    git clone https://github.com/GmSSL/OpenSSL-Compatibility-Layer.git
    rm -rf nginx-1.24.0.tar.gz
    wget http://nginx.org/download/nginx-1.24.0.tar.gz
    tar zxvf nginx-1.24.0.tar.gz
    
    cd ./GmSSL/
    mkdir build && cd build
    cmake ..
    make
    make test
    make install
    
    cd ../../OpenSSL-Compatibility-Layer/
    mkdir build && cd build
    cmake ..
    make
    make install
    ldconfig
    
    cd ../../nginx-1.24.0/
    ./configure --with-http_ssl_module --with-debug --without-http_rewrite_module
    make
    make install
    /usr/local/nginx/sbin/nginx -v
    
  11. wlh1024 commented on Jan 3, 2025

    @wlh1024

    都解决了吗
    只有OpenSSL-Compatibility-Layer编译报错的问题解决了,Nginx还在尝试

    你看看这个报错和这个类似不:#4 解决方法是删掉本机的libssl-dev,以免冲突

    非常感谢,缺失的头文件从openssl考过来就可以了,编译已经没有问题了。 但是现在遇到一个新的问题,希望指点一二,链接时,希望是静态链接,但是OPL标准编译只有动态库,如何能生成静态库?

    请问大佬解决了吗,我现在编译nginx也碰到这个问题,不知道接下来要怎么搞

    我的nginx编译参数为:
    cd nginx-1.24.0 & auto/./configure.
    --with-debug
    --prefix=../nginx
    --sbin-path=nginx
    --conf-path=conf/nginx.conf
    --pid-path=logs/nginx.pid
    --http-log-path=logs/access.log
    --error-log-path=logs/error.1og
    --http-client-body-temp-path=tempclient body temp
    --http-proxy-temp-path=temp/proxy_temp
    --http-fastcgi-temp-path=temp/fastcgi_temp
    --http-scgi-temp-path=temp/scgi_temp
    --http-uwsgi-temp-path=temp/uwsgi_temp
    --with-http realip module
    --with-http_v2_module
    --with-http_ssl_module
    --with-zlib=../zlib-1.3.1
    --with-pcre=../pcre-8.45
    --with-stream
    --with-stream ssl module
    --add-module=../headers-more-nginx-module

    不指定openssl的地址的话,编译的nginx会启动报错./nginx: error while loading shared libraries: libssl.so: cannot open shared object file: No such file or directory

  12. wlh1024 commented on Jan 3, 2025

    @wlh1024

    我之前也遇到过这个问题,然后莫名其妙消失了,好像是config的时候不指定openssl的地址就行?

    你按这个流程试试

    删掉本机的libssl-dev,然后重新编译安装GmSSL和OCL的master版本,再从源码编译安装nginx-1.24.0

    这是我在阿里云一台空白ubuntu22.04机器上从头安装的脚本,你可以参考一下

    #!/bin/bash
    
    apt-get update
    apt-get install cmake git -y
    
    rm -rf GmSSL
    git clone https://github.com/guanzhi/GmSSL.git
    rm -rf OpenSSL-Compatibility-Layer
    git clone https://github.com/GmSSL/OpenSSL-Compatibility-Layer.git
    rm -rf nginx-1.24.0.tar.gz
    wget http://nginx.org/download/nginx-1.24.0.tar.gz
    tar zxvf nginx-1.24.0.tar.gz
    
    cd ./GmSSL/
    mkdir build && cd build
    cmake ..
    make
    make test
    make install
    
    cd ../../OpenSSL-Compatibility-Layer/
    mkdir build && cd build
    cmake ..
    make
    make install
    ldconfig
    
    cd ../../nginx-1.24.0/
    ./configure --with-http_ssl_module --with-debug --without-http_rewrite_module
    make
    make install
    /usr/local/nginx/sbin/nginx -v
    

    我本机没有libssl-dev,编译nginx不会报错,但编译的nginx会启动报错./nginx: error while loading shared libraries: libssl.so: cannot open shared object file: No such file or directory
    image

  13. wlh1024 commented on Jan 3, 2025

    @wlh1024

    我之前也遇到过这个问题,然后莫名其妙消失了,好像是config的时候不指定openssl的地址就行?

    你按这个流程试试

    删掉本机的libssl-dev,然后重新编译安装GmSSL和OCL的master版本,再从源码编译安装nginx-1.24.0

    这是我在阿里云一台空白ubuntu22.04机器上从头安装的脚本,你可以参考一下

    #!/bin/bash
    
    apt-get update
    apt-get install cmake git -y
    
    rm -rf GmSSL
    git clone https://github.com/guanzhi/GmSSL.git
    rm -rf OpenSSL-Compatibility-Layer
    git clone https://github.com/GmSSL/OpenSSL-Compatibility-Layer.git
    rm -rf nginx-1.24.0.tar.gz
    wget http://nginx.org/download/nginx-1.24.0.tar.gz
    tar zxvf nginx-1.24.0.tar.gz
    
    cd ./GmSSL/
    mkdir build && cd build
    cmake ..
    make
    make test
    make install
    
    cd ../../OpenSSL-Compatibility-Layer/
    mkdir build && cd build
    cmake ..
    make
    make install
    ldconfig
    
    cd ../../nginx-1.24.0/
    ./configure --with-http_ssl_module --with-debug --without-http_rewrite_module
    make
    make install
    /usr/local/nginx/sbin/nginx -v
    

    大佬方便留个QQ或者微信交流一下吗

  14. PikaByter commented on Jan 3, 2025

    @PikaByter

    大佬方便留个QQ或者微信交流一下吗

    建议你用 铜锁 吧,我把这个问题解决后,卡在nginx插件的国产化适配上了,这个项目转型一半已经没人维护了,所以只能换整个方案

  15. daichengxu commented on Jan 6, 2025

    @daichengxu

    我之前也遇到过这个问题,然后莫名其妙消失了,好像是config的时候不指定openssl的地址就行?
    你按这个流程试试
    删掉本机的libssl-dev,然后重新编译安装GmSSL和OCL的master版本,再从源码编译安装nginx-1.24.0
    这是我在阿里云一台空白ubuntu22.04机器上从头安装的脚本,你可以参考一下

    #!/bin/bash
    
    apt-get update
    apt-get install cmake git -y
    
    rm -rf GmSSL
    git clone https://github.com/guanzhi/GmSSL.git
    rm -rf OpenSSL-Compatibility-Layer
    git clone https://github.com/GmSSL/OpenSSL-Compatibility-Layer.git
    rm -rf nginx-1.24.0.tar.gz
    wget http://nginx.org/download/nginx-1.24.0.tar.gz
    tar zxvf nginx-1.24.0.tar.gz
    
    cd ./GmSSL/
    mkdir build && cd build
    cmake ..
    make
    make test
    make install
    
    cd ../../OpenSSL-Compatibility-Layer/
    mkdir build && cd build
    cmake ..
    make
    make install
    ldconfig
    
    cd ../../nginx-1.24.0/
    ./configure --with-http_ssl_module --with-debug --without-http_rewrite_module
    make
    make install
    /usr/local/nginx/sbin/nginx -v
    

    我本机没有libssl-dev,编译nginx不会报错,但编译的nginx会启动报错./nginx: error while loading shared libraries: libssl.so: cannot open shared object file: No such file or directory image

    centos系统把这个openssl-devel卸载就好了
    yum remove -y openssl-devel

  16. wlh1024 commented on Jan 6, 2025

    @wlh1024

    我之前也遇到过这个问题,然后莫名其妙消失了,好像是config的时候不指定openssl的地址就行?
    你按这个流程试试
    删掉本机的libssl-dev,然后重新编译安装GmSSL和OCL的master版本,再从源码编译安装nginx-1.24.0
    这是我在阿里云一台空白ubuntu22.04机器上从头安装的脚本,你可以参考一下

    #!/bin/bash
    
    apt-get update
    apt-get install cmake git -y
    
    rm -rf GmSSL
    git clone https://github.com/guanzhi/GmSSL.git
    rm -rf OpenSSL-Compatibility-Layer
    git clone https://github.com/GmSSL/OpenSSL-Compatibility-Layer.git
    rm -rf nginx-1.24.0.tar.gz
    wget http://nginx.org/download/nginx-1.24.0.tar.gz
    tar zxvf nginx-1.24.0.tar.gz
    
    cd ./GmSSL/
    mkdir build && cd build
    cmake ..
    make
    make test
    make install
    
    cd ../../OpenSSL-Compatibility-Layer/
    mkdir build && cd build
    cmake ..
    make
    make install
    ldconfig
    
    cd ../../nginx-1.24.0/
    ./configure --with-http_ssl_module --with-debug --without-http_rewrite_module
    make
    make install
    /usr/local/nginx/sbin/nginx -v
    

    我本机没有libssl-dev,编译nginx不会报错,但编译的nginx会启动报错./nginx: error while loading shared libraries: libssl.so: cannot open shared object file: No such file or directory image

    centos系统把这个openssl-devel卸载就好了 yum remove -y openssl-devel

    可我本地没有这个
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions