/usr/include/fastdfs/fdfs_define.h:15:27: fatal error: common_define.h: No such file or 的解决办法

问题概述

在项目使用到了分布式文件服务器FastDFS,FastDFS的Tracker Server 和 Storage Server 安装完成后,需要外部的 Web Server来提供访问,有人可能会疑问,为什么不使用FastDFS内部的Web Server呢,我的另一篇文章非常详细的阐述了这个问题,请参看 《 FastDFS分布式文件系统内部架构及其原理解析 》

这儿使用的是FastDFS的Nginx扩展模块,但是在Nginx编译时出现了错误,“ fatal error: common_define.h: No such file or directory

如下图:

 

 

解决办法

经过了系统的排查,最终得知,在安装FastDFS的时候,其中的函数声明、宏定义、函数原型被指到了 “ /usr/include/fastdfs /usr/include/fastcommon ” 目录下,如下图:

 

而Nginx的扩展模块配置文件默认指定的目录为 “ /usr/include ”,找不到文件,才导致的上面的错误 “ 致命错误: common_define.h 的文件或目录不存在 ” ,解决这个问题,只需要将Nginx扩展模块的路径目录修改为上面正常的 “ /usr/include/fastdfs ” 即可,输入命令 “ vi /usr/local/fastdfs-nginx-module/src/config ” ,总共修改两项即可:

ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"

》》》

CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

缺省的:

ngx_addon_name=ngx_http_fastdfs_module

if test -n "${ngx_module_link}"; then
    ngx_module_type=HTTP
    ngx_module_name=$ngx_addon_name
    ngx_module_incs="/usr/include"
    ngx_module_libs="-lfastcommon -lfdfsclient"
    ngx_module_srcs="$ngx_addon_dir/ngx_http_fastdfs_module.c"
    ngx_module_deps=
    CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"
    . auto/module
else
    HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
    NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
    CORE_INCS="$CORE_INCS /usr/include"
    CORE_LIBS="$CORE_LIBS -lfastcommon -lfdfsclient"
    CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"
fi

修改后的:

ngx_addon_name=ngx_http_fastdfs_module

if test -n "${ngx_module_link}"; then
    ngx_module_type=HTTP
    ngx_module_name=$ngx_addon_name
    ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
    ngx_module_libs="-lfastcommon -lfdfsclient"
    ngx_module_srcs="$ngx_addon_dir/ngx_http_fastdfs_module.c"
    ngx_module_deps=
    CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"
    . auto/module
else
    HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
    NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
    CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
    CORE_LIBS="$CORE_LIBS -lfastcommon -lfdfsclient"
    CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"
fi

现在再去编译安装Nginx就可以了。

 

 

 

 

 


 好了,关于 fatal error: common_define.h: No such file or directory 的解决办法 就写到这儿了,如果还有什么疑问或遇到什么问题欢迎扫码提问,也可以给我留言哦,我会一一详细的解答的。 
歇后语:“ 共同学习,共同进步 ”,也希望大家多多关注CSND的IT社区。


作       者: 华    仔
联系作者: [email protected]
来        源: CSDN (Chinese Software Developer Network)
原        文: https://blog.csdn.net/Hello_World_QWP/article/details/95318414
版权声明: 本文为博主原创文章,请在转载时务必注明博文出处!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章