c++ - 构建 nginx 和 OpenSSL 时出错

标签 c++ gcc nginx openssl makefile

我正在尝试使用最新的 OpenSSL 构建最新的 nginx 版本。构建过程退出并显示以下消息。

/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make[4]: *** [link_app.] Error 1
make[4]: Leaving directory `/tmp/openssl-1.0.1e/test'
make[3]: *** [md2test] Error 2
make[3]: Leaving directory `/tmp/openssl-1.0.1e/test'
make[2]: *** [build_tests] Error 1
make[2]: Leaving directory `/tmp/openssl-1.0.1e'
make[1]: *** [/tmp/openssl-1.0.1e/.openssl/include/openssl/ssl.h] Error 2
make[1]: Leaving directory `/tmp/nginx-1.4.0'
make: *** [build] Error 2

我的 nginx 配置调用如下所示:

./configure
  --prefix=/usr/local
  --sbin-path=/usr/local/sbin
  --conf-path=/etc/nginx/nginx.conf
  --pid-path=/var/run/nginx.pid
  --lock-path=/var/lock/nginx.lock
  --error-log-path=/var/log/nginx/error.log
  --http-log-path=/var/log/nginx/access.log
  --http-client-body-temp-path=/dev/shm/nginx/client-body/tmp
  --http-fastcgi-temp-path=/dev/shm/nginx/fastcgi/tmp
  --with-pcre=/tmp/pcre-8.32
  --with-openssl=/tmp/openssl-1.0.1e
  --with-zlib=/tmp/zlib
  --with-cc-opt='-O3 -m64'
  --with-ld-opt='-m64'
  --with-ipv6
  --with-http_gzip_static_module
  --with-http_ssl_module
  --with-http_spdy_module
  --with-md5=/tmp/openssl-1.0.1e
  --with-md5-asm
  --with-sha1=/tmp/openssl-1.0.1e
  --with-sha1-asm
  --with-pcre-jit
  --without-http_autoindex_module
  --without-http_auth_basic_module
  --without-http_browser_module
  --without-http_geo_module
  --without-http_limit_conn_module
  --without-http_limit_req_module
  --without-http_map_module
  --without-http_memcached_module
  --without-http_proxy_module
  --without-http_referer_module
  --without-http_scgi_module
  --without-http_split_clients_module
  --without-http_ssi_module
  --without-http_upstream_ip_hash_module
  --without-http_userid_module
  --without-http_uwsgi_module
  --without-mail_pop3_module
  --without-mail_imap_module
  --without-mail_smtp_module
  --add-module=/tmp/nginx-upload-progress-module
  --add-module=/tmp/nginx-upstream-fair

我知道这是某种 gcc 链接器问题,我已经尝试了几个 -lxxx 标志(从与我的问题类似的其他 StackOverflow 线程获取它们)但没有任何帮助。我也尝试过使用较旧的 nginx/OpenSSL 版本,但没有成功。保留 -O3-m64 编译器标志也是如此。

关于环境的更多信息:

gcc (Debian 4.7.2-5) 4.7.2
cpp (Debian 4.7.2-5) 4.7.2
pcre 8.32
zlib and modules are cloned from git master

最佳答案

我终于能够编译nginx了,当然我想和你分享一下。似乎配置选项的顺序是问题所在。我使用了以下配置参数顺序并且编译没有任何问题。

nginx version: nginx/1.4.0
built by gcc 4.7.2 (Debian 4.7.2-5)
TLS SNI support enabled
configure arguments:
  --user=www-data
  --group=www-data
  --prefix=/usr/local
  --sbin-path=/usr/local/sbin
  --conf-path=/etc/nginx/nginx.conf
  --pid-path=/var/run/nginx.pid
  --lock-path=/var/lock/nginx.lock
  --error-log-path=/var/log/nginx/error.log
  --http-log-path=/var/log/nginx/access.log
  --http-client-body-temp-path=/dev/shm/nginx/client-body/tmp
  --http-fastcgi-temp-path=/dev/shm/nginx/fastcgi/tmp
  --with-ipv6
  --with-http_gzip_static_module
  --with-http_ssl_module
  --with-http_spdy_module
  --with-openssl=/usr/local/src/nginx/openssl-1.0.1e
  --with-md5=/usr/local/src/nginx/openssl-1.0.1e
  --with-md5-asm
  --with-sha1=/usr/local/src/nginx/openssl-1.0.1e
  --with-sha1-asm
  --with-pcre=/usr/local/src/nginx/pcre-8.32
  --with-pcre-jit
  --with-zlib=/usr/local/src/nginx/zlib
  --without-http_autoindex_module
  --without-http_auth_basic_module
  --without-http_browser_module
  --without-http_geo_module
  --without-http_limit_conn_module
  --without-http_limit_req_module
  --without-http_map_module
  --without-http_memcached_module
  --without-http_proxy_module
  --without-http_referer_module
  --without-http_scgi_module
  --without-http_split_clients_module
  --without-http_ssi_module
  --without-http_upstream_ip_hash_module
  --without-http_userid_module
  --without-http_uwsgi_module
  --without-mail_pop3_module
  --without-mail_imap_module
  --without-mail_smtp_module
  --add-module=/usr/local/src/nginx/nginx-upload-progress-module
  --add-module=/usr/local/src/nginx/nginx-upstream-fair

关于c++ - 构建 nginx 和 OpenSSL 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16245589/

相关文章:

c++ - 需要对 C++ 中 Table 类的两个成员函数的反馈

c++ - Flex Lexer 工具中的类 istream

c - 如何在 ELF 文件中制作重复的部分

运行在nginx和uwsgi上的django项目中python进程启动需要时间

vue.js - 获取 : ERR_SSL_PROTOCOL_ERROR nginx + vue. js

c++ - 模板特化不明确

c++ - flash.net.Socket 和 C++ winsock WSAECONNRESET

gcc - C 编译器无法创建可执行文件 Ubuntu 10.04 LTS

ios - Xcode "Do not submit apps with GCC-style coverage"iOS上传处理错误

Docker Compose 和 Nginx 反向代理 : I can't access the backend through the proxy