Open iamabug opened 6 years ago
我自己用TARGET_CONF_PATH替换了/etc/fdfs之后,编译和安装没有问题,但是运行fdfs时提示找不到libfastcommon.so
fdfs_trackerd: error while loading shared libraries: libfastcommon.so: cannot open shared object file: No such file or directory
所以我手动指定LD_LIBRARY_PATH
到libfastcommon.so的路径,再次运行,此时报另外一个错误:
[2018-09-27 10:52:42] ERROR - file: shared_func.c, line: 212, can't find exe file fdfs_trackerd! [2018-09-27 10:52:42] CRIT - exit abnormally!
根据这个报错信息,可以找到fastcommon的源码,在fdfs_shared_func.c的getExeAbsoluteFilename函数中,有如下代码:
`
const char *filename;
const char *p;
int nFileLen;
int nPathLen;
char cwd[256];
char szPath[1024];
nFileLen = strlen(exeFilename);
if (nFileLen >= sizeof(szPath))
{
logError("file: "__FILE__", line: %d, " \
"filename length: %d is too long, exceeds %d!", \
__LINE__, nFileLen, (int)sizeof(szPath));
return NULL;
}
p = strrchr(exeFilename, '/');
if (p == NULL)
{
int i;
char *search_paths[] = {"/bin", "/usr/bin", "/usr/local/bin"};
*szPath = '\0';
filename = exeFilename;
for (i=0; i<3; i++)
{
snprintf(cwd, sizeof(cwd), "%s/%s", \
search_paths[i], filename);
if (fileExists(cwd))
{
strcpy(szPath, search_paths[i]);
break;
}
}
if (*szPath == '\0')
{
if (!fileExists(filename))
{
logError("file: "__FILE__", line: %d, " \
"can't find exe file %s!", __LINE__, \
filename);
return NULL;
}
}
` 这里的含义是不是说,调用libfastcommon的程序必须在/bin, /usr/bin, /usr/local/bin 这三个目录?如果是这样的话,那么fastdfs就不支持安装在系统目录以外的地方了?
make.sh开头有这几句支持安装在非标准路径:
TARGET_PREFIX=$DESTDIR/usr
TARGET_CONF_PATH=$DESTDIR/etc/fdfs
TARGET_INIT_PATH=$DESTDIR/etc/init.d
但是在156-157行这里,还是硬编码了系统/etc/fdfs路径:
if [ ! -d /etc/fdfs ]; then
mkdir -p /etc/fdfs
执行
DESTDIR=[MY_DIR] ./make.sh install
就会提示权限不足:mkdir cannot create directory '/etc/fdfs': Permission denied
请各位大佬帮忙看下,谢谢~