【问题标题】:string.h:29:8: error: expected identifierstring.h:29:8:错误:预期标识符
【发布时间】:2015-04-29 10:53:35
【问题描述】:

我正在尝试使用以下脚本通过自定义 openssl »libressl« 编译 nginx:https://gist.github.com/Belphemur/3c022598919e6a1788fc

使用 libressl 2.1.1 一切正常。 问题是 libressl 2.1.1 存在一些安全问题,新版本已解决。
但是我无法让构建与 libressl 2.1.2 或 libressl 2.1.3(最新版本)一起使用。

我遇到的问题:

..
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 /tmp/build/pcre-8.36 -I /tmp/build/libressl-2.1.2/.openssl/include -I objs \
        -o objs/src/core/nginx.o \
        src/core/nginx.c
In file included from /usr/include/string.h:635:0,
                 from /tmp/build/libressl-2.1.2/.openssl/include/string.h:6,
                 from src/os/unix/ngx_linux_config.h:27,
                 from src/core/ngx_config.h:26,
                 from src/core/nginx.c:8:
/tmp/build/libressl-2.1.2/.openssl/include/string.h:29:8: error: expected identifier or ‘(’ before ‘__extension__’
 char * strndup(const char *str, size_t maxlen);
        ^
make[1]: *** [objs/src/core/nginx.o] Error 1
make[1]: Leaving directory `/tmp/build/nginx-1.7.9'
make: *** [build] Error 2
All done.
..

问题出在哪里以及如何解决?
感谢您的帮助。

【问题讨论】:

    标签: ssl nginx libressl


    【解决方案1】:

    我是您使用 LibreSSL 构建 Nginx 的脚本的创建者。

    现在更正了,以前构建和使用 libressl 的方法不适用于以前版本的脚本。 (只需复制所有包含并剥离库)

    脚本现在将 libressl 安装在一个设置的目录中并将其交给 nginx,这样,所有不需要使用该库的包含(如这个 string.h)都不是 nginx 构建过程的一部分。

    【讨论】:

      【解决方案2】:

      strndupstring.h 中提供。您无需在此处提供:

      /tmp/build/libressl-2.1.2/.openssl/include/string.h:29:8: error: expected identifier or ‘(’ before ‘__extension__’
      char * strndup(const char *str, size_t maxlen);
      

      我会从源中删除string.h 的副本,并将平台提供的string.h 用于strndup

      事实上,我不知道string.h 来自哪里,因为它不存在于我的系统中(而且我经常构建和使用最新的 OpenSSL):

      $ find /usr/local/ssl/ -name string.h
      $ find /usr/local/ssl/ -name *.h
      /usr/local/ssl/include/openssl/rc4.h
      /usr/local/ssl/include/openssl/crypto.h
      /usr/local/ssl/include/openssl/ts.h
      /usr/local/ssl/include/openssl/ecdsa.h
      /usr/local/ssl/include/openssl/opensslconf.h
      ...
      

      我正在尝试使用以下脚本通过自定义 openssl »libressl« 编译 nginx:https://gist.github.com/Belphemur/3c022598919e6a1788fc

      好的,这可能会很痛苦,因为我不得不对 nginx(FIPS 验证的 OpenSSL)做类似的事情。

      处理它的最简单方法是从源代码构建 OpenSSL 并将其安装到 /usr/local/ssl。然后,grep nginx 的 -lcrypto-lssl 文件。找到它们后,将它们替换为 OpenSSL 的静态存档:

      • -lcrypto 更改为/usr/local/ssl/lib/libcrypto.a
      • -lssl 更改为/usr/local/ssl/lib/libssl.a

      并删除与 OpenSSL 相关的 -L

      这将确保您在编译时和运行时使用您的 OpenSSL 版本,而无需 LD_PRELOADDYLD_LIBRARY_PATH 技巧。它总是有效的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-07-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多