Mysql 使用依赖库编译nginx模块
我按照这里的教程成功构建了一个简单的nginx模块: 我可以毫无问题地构建和运行代码,并且它可以正常运行 现在我想将MySQL的依赖性添加到简单的nginx模块中,因此我使用了MySQL C连接器 您可以编写的最简单程序如下(摘自): mysql_test.cMysql 使用依赖库编译nginx模块,mysql,c,nginx,Mysql,C,Nginx,我按照这里的教程成功构建了一个简单的nginx模块: 我可以毫无问题地构建和运行代码,并且它可以正常运行 现在我想将MySQL的依赖性添加到简单的nginx模块中,因此我使用了MySQL C连接器 您可以编写的最简单程序如下(摘自): mysql_test.c #include <my_global.h> #include <mysql.h> int main(int argc, char **argv) { printf("MySQL client versio
#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);
}
这个很好用
现在,当我尝试在简单的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
cc-c-pipe-O-W-Wall-Wpointer arith-Wno未使用的参数-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:致命错误:my_global.h:没有这样的文件或目录
#包括
^
编译终止。
make[1]:***[objs/addon/nginx hello world module/ngx_http_hello_world_module.o]错误1
make[1]:离开目录“/vagrant/nginx”
生成:**[build]错误2
我的问题是:如何让nginx在构建模块时包含这些构建标志
我没有找到任何关于使用Nginx构建依赖关系的信息
谢谢
编译控件
--带有cc opt=参数
设置将添加到CFLAGS变量的其他参数
--带有ld opt=参数
设置链接期间将使用的其他参数
对于MySQL连接器C,它将类似于:
--with-cc-opt="-I/usr/include/mysql"
--with-ld-opt="-L/usr/lib64/mysql"
在模块的config
文件中:
CORE_LIBS="$CORE_LIBS -lmysqlclient"
在编译过程中,它还可能会抱怨\GNU\u SOURCE
被重新定义,如果您使用-Werror
而不实施变通方法,它将失败
CORE_LIBS="$CORE_LIBS -lmysqlclient"