【发布时间】:2016-01-27 23:59:29
【问题描述】:
我已经按照这里的教程成功构建了一个简单的 nginx 模块:https://github.com/perusio/nginx-hello-world-module
我可以毫无问题地构建和运行该代码,并且它可以正常运行。
我现在想将 MySQL 的依赖添加到简单的 nginx 模块中,所以我使用了 MySQL C 连接器http://dev.mysql.com/doc/refman/5.6/en/c-api-building-clients.html。
你能写的最简单的程序是这个(取自http://zetcode.com/db/mysqlc/):
mysql_test.c
#include <my_global.h>
#include <mysql.h>
int main(int argc, char **argv)
{
printf("MySQL client version: %s\n", mysql_get_client_info());
exit(0);
}
然后你像这样编译:
$ gcc mysql_test.c -o mysql_test `mysql_config --cflags --libs`
这很好用。
现在,当我尝试在我的简单 nginx hello-world 模块中包含两个头文件 my_global.h 和 mysql.h 时,我需要一种指定这些构建标志的方法,否则它将找不到这些头文件。目前,当我运行make,它成功构建所有其他模块后,我现在得到:
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 objs -I src/http -I src/http/modules -I src/mail \
-o objs/addon/nginx-hello-world-module/ngx_http_hello_world_module.o \
/vagrant/nginx-hello-world-module/ngx_http_hello_world_module.c
/vagrant/nginx-hello-world-module/ngx_http_hello_world_module.c:33:23: fatal error: my_global.h: No such file or directory
#include <my_global.h>
^
compilation terminated.
make[1]: *** [objs/addon/nginx-hello-world-module/ngx_http_hello_world_module.o] Error 1
make[1]: Leaving directory `/vagrant/nginx'
make: *** [build] Error 2
我的问题是:如何让 nginx 在构建我的模块时包含这些构建标志?
我还没有找到任何关于使用 Nginx 构建依赖项的信息。
谢谢!
【问题讨论】: