我尝试在 Ubuntu 11.10(gcc 版本 4.6)上使用此处的 nginx 模块编译支持 gridfs(nginx-gridfs 版本 0.8)的 nginx(版本 1.0.11):
https://github.com/mdirolf/nginx-gridfs
那里描述的安装说明很简单:
* Clone the nginx-gridfs repository (`git clone https://github.com/mdirolf/nginx-gridfs`)
* Check out the mongo-c-driver submodule (`git submodule init` then `git submodule update`)
* Download and unpack the nginx source (from `http://nginx.org/download/nginx-1.0.11.tar.gz`)
* Run `./configure` with `--add-module=/path/to/nginx-gridfs/repository`
* `make` and `sudo make install`
上次我在一台机器上设置 nginx-gridfs 时(大约四个月前,在 Ubuntu 10.04 上,使用 gcc 4.5 和 nginx 版本 1.0.5),这些步骤对我来说很有效,但现在(在全新安装的 Ubuntu 上)我收到错误。 运行./configure
正常,但make
失败了:
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c: In function 'mongo_count':
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c:939:5: error: missing initializer [-Werror=missing-field-initializers]
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c:939:5: error: (near initialization for 'out.dataSize') [-Werror=missing-field-initializers]
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c: In function 'mongo_simple_int_command':
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c:981:5: error: missing initializer [-Werror=missing-field-initializers]
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c:981:5: error: (near initialization for 'out.dataSize') [-Werror=missing-field-initializers]
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c: In function 'mongo_simple_str_command':
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c:1013:5: error: missing initializer [-Werror=missing-field-initializers]
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c:1013:5: error: (near initialization for 'out.dataSize') [-Werror=missing-field-initializers]
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c: In function 'mongo_cmd_get_error_helper':
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c:1055:5: error: missing initializer [-Werror=missing-field-initializers]
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c:1055:5: error: (near initialization for 'out.dataSize') [-Werror=missing-field-initializers]
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c: In function 'mongo_cmd_ismaster':
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c:1098:5: error: missing initializer [-Werror=missing-field-initializers]
/path/to/nginx-gridfs/mongo-c-driver/src/mongo.c:1098:5: error: (near initialization for 'out.dataSize') [-Werror=missing-field-initializers]
cc1: all warnings being treated as errors
make[1]: *** [objs/addon/src/mongo.o] Error 1
知道为什么这会失败吗?
这cc1: all warnings being treated as errors
让我相信我可能能够添加-Wno-error
以CFLAGS
告诉它不要将警告视为错误以避免此问题。但我担心这里出于某种原因启用了 treat-warnings-as-errors,而将其关闭只会使编译表面上成功,但实际上不起作用。
有人知道这里发生了什么事吗?
答案1
使用忽略警告方法使编译工作正常,但实际上我使用的用户/密码错误导致无法连接到数据库。对我而言,有效的方法是从头开始构建 mongo 以向 nginx 构建提供较新的库:http://pastebin.com/tMsL2eC9
但这还不够。我还必须专门检查 nginx-gridfs 子模块中的 mongo c 驱动程序 v0.3.1。也就是说,nginx gridfs 的 v0.8。v0.3.1 mongo c 驱动程序和新的 mongo 构建都是从该链接中指定的环境引用的。然后我构建了 nginx 1.0.11,没有任何错误,并且它工作正常。