首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >string.h:29:8:错误:预期标识符

string.h:29:8:错误:预期标识符
EN

Stack Overflow用户
提问于 2015-02-26 21:24:38
回答 2查看 1.4K关注 0票数 3

我试图用自定义openssl编译nginx,使用以下脚本:https://gist.github.com/Belphemur/3c022598919e6a1788fc

使用libressl 2.1.1,一切都很好。问题是libressl 2.1.1存在一些安全问题,这些问题已经由较新的版本解决。

但是,我无法让构建使用libressl 2.1.2或LibreSSL2.1.3(最新版本)。

我遇到的问题是:

代码语言:javascript
复制
..
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.
..

问题是什么&如何解决?

谢谢你的帮助。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-03-02 14:48:42

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

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

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

票数 2
EN

Stack Overflow用户

发布于 2015-02-28 00:19:37

strndup是以string.h提供的。你不需要在这里提供:

代码语言:javascript
复制
/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的副本,并使用平台为strndup提供的string.h

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

代码语言:javascript
复制
$ 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编译nginx,使用以下脚本:https://gist.github.com/Belphemur/3c022598919e6a1788fc

好的,这可能是一个痛苦,因为我不得不做类似的nginx (FIPS验证的OpenSSL)。

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

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

并删除与-L相关的OpenSSL。

这将确保您在编译时和运行时使用您的OpenSSL版本,而不需要使用LD_PRELOADDYLD_LIBRARY_PATH技巧。一切都会成功的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28753021

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档