# Nginx 1.0.11 + upload module compile error

**URL:** <https://www.ruby-forum.com/t/nginx-1-0-11-upload-module-compile-error/217515>\
**Category:** NGINX\
**Created:** [March 3, 2012, 7:00pm UTC](https://www.ruby-forum.com/t/nginx-1-0-11-upload-module-compile-error/217515 "2012-03-03T19:00:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 3, 2012, 7:00pm UTC](https://www.ruby-forum.com/t/nginx-1-0-11-upload-module-compile-error/217515/1 "2012-03-03T19:00:26Z")

</div>

Hi all,

This is my nginx setup:

- nginx 1.0.11
- nginx-upload-module 2.2.0  
([http://www.grid.net.ru/nginx/upload.en.html](http://www.grid.net.ru/nginx/upload.en.html))

I can compile from source with --add-module flag on:

- OS X Snow Leopard (gcc version 4.2.1)
- Ubuntu 10.10 (gcc version 4.4.3)

But compilation failed on Kubuntu 11.10 (gcc version 4.6.1)

It failed because the http upload module defined a variable but the  
compiler claimed it wasn’t used and fails compilation.

Below is snippet inside ngx\_http\_upload\_module.c

static ngx\_int\_t /\* {{{ ngx\_http\_upload\_merge\_ranges \*/  
ngx\_http\_upload\_merge\_ranges(ngx\_http\_upload\_ctx\_t \*u,  
ngx\_http\_upload\_range\_t \*range\_n) {

```
int result;

/* Some more code .... */

// This is where it is being called.
if(out_buf.file_pos < state_file->info.st_size) { result =

```

ftruncate(state\_file-\>fd, out\_buf.file\_pos); }  
}

If I change objs/Makefile to ignore warning, compilation works just  
fine. But obviously nginx likes to compile with strict rules. Inside  
objs/Makefile:

CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter  
-Wunused-function -Wunused-variable -Wunused-value -Werror

So my questions are:

- Is this the module’s fault?

- Different gcc versions works differently? (I’m a noob in C)

- Is there a way to fix it without editing objs/Makefile? I prefer to  
keep nginx source code as-is. And I’m ok to change the source code of  
the module because it looks abandoned anyway.

Posted at Nginx Forum:

> **[nginx 1.0.11 + upload module compile error.](https://forum.nginx.org/read.php?2,223298,223298#msg-223298)**
>
> Hi all, This is my nginx setup: \* nginx 1.0.11 \* nginx-upload-module 2.2.0 (http://www.grid.net.ru/nginx/upload.en.html) I can compile from source with --add-module flag on: \* OS X Snow Leopard (gcc version 4.2.1) \* Ubuntu 10.
