我也跟着教程這裏構建一個簡單的nginx模塊的成功:https://github.com/perusio/nginx-hello-world-module編譯nginx的模塊依賴庫
我可以生成並運行該代碼沒有問題,它能夠正確工作。
我現在想添加一個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`
這工作得很好。
現在,當我嘗試包括兩個頭文件my_global.h
和mysql.h
我簡單的nginx你好世界模塊,我需要那些指定的方式建立的標誌,否則將無法找到這些頭文件。此刻,當我運行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構建依賴項的信息。
謝謝!