Nginx – Compiling nginx with nginx-gridfs, getting mongo-c-driver errors during make

nginxUbuntuubuntu-11.04

I'm attempting to compile nginx (version 1.0.11) with gridfs support (nginx-gridfs version 0.8) on Ubuntu 11.10 (gcc version 4.6) using the nginx module here:

https://github.com/mdirolf/nginx-gridfs

The installation instructions described there are simple:

* 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`

These steps worked fine for me last time I set up nginx-gridfs on a machine (about four months ago on Ubuntu 10.04, with gcc 4.5 and nginx version 1.0.5), but now (on a fresh Ubuntu install) I'm getting an error. The ./configure is working fine, but make fails with:

/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

Any idea why this would fail?

The cc1: all warnings being treated as errors leads me to believe that I may be able to add -Wno-error to CFLAGS to tell it not treat warnings as errors to avoid this issue. But I'm worried that treat-warnings-as-errors is enabled here for a reason, and that turning it off would only make the compilation successful on the surface, but not actually work.

Anyone know what's going on here?

Best Answer

Using your ignore warnings methods made the compilation work but I would actually get failure to connect to the database with user/password errors in use. What worked for me was a combination of building mongo from scratch to supply nginx build with newer libs: http://pastebin.com/tMsL2eC9

But this wasnt actually enough. I also had to specifically check out mongo c driver v0.3.1 in the submodule of nginx-gridfs. So that is, v0.8 of nginx gridfs. V0.3.1 mongo c driver, and the fresh mongo build being references from the env specified in that link. Then I built nginx 1.0.11 with no errors and it worked.

Related Topic