Skip to content

Loading…

Ubuntu 12.04 Server Error #26

Closed
sbilly opened this Issue · 5 comments

3 participants

@sbilly

虽然可以搞,但还是报个 issuse 吧

make

cd src && make all
make[1]: Entering directory /tmp/zlog-master/src'
cc -std=c99 -pedantic -c -O2 -fPIC -Wall -Werror -Wstrict-prototypes -g -ggdb buf.c
cc -std=c99 -pedantic -c -O2 -fPIC -Wall -Werror -Wstrict-prototypes -g -ggdb category.c
cc -std=c99 -pedantic -c -O2 -fPIC -Wall -Werror -Wstrict-prototypes -g -ggdb category_table.c
cc -std=c99 -pedantic -c -O2 -fPIC -Wall -Werror -Wstrict-prototypes -g -ggdb conf.c
conf.c: In function ‘zlog_conf_build_with_file’:
conf.c:246:2: error: implicit declaration of function ‘lstat’ [-Werror=implicit-function-declaration]
conf.c:251:2: error: implicit declaration of function ‘localtime_r’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
make[1]: *** [conf.o] Error 1
make[1]: Leaving directory
/tmp/zlog-master/src'
make: *** [all] Error 2

@HardySimpson

第2个我知道,是没有include

第一个是为什么呢?我man一下lstat,看见只要包含这3个文件就行啊。。。

   #include <sys/types.h>
   #include <sys/stat.h>
   #include <unistd.h>

   int stat(const char *path, struct stat *buf);
   int fstat(int fd, struct stat *buf);
   int lstat(const char *path, struct stat *buf);
@lisongmin

这样是ok的:
cc -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -std=c99 -pedantic -O2 -g -Wall -Wstrict-prototypes -o CMakeFiles/zlog_s.dir/conf.c.o -c /media/workspace/third_project/zlog/src/conf.c

@HardySimpson

呃,仔细观察了一下,lstat需要

SYNOPSIS
       #include <sys/types.h>
       #include <sys/stat.h>
       #include <unistd.h>

       int stat(const char *path, struct stat *buf);
       int fstat(int fd, struct stat *buf);
       int lstat(const char *path, struct stat *buf);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       lstat(): _BSD_SOURCE || _XOPEN_SOURCE >= 500

不过在我的fmacros.h里面,已经吧这两个申明了

#define _BSD_SOURCE

#if defined(__linux__) || defined(__OpenBSD__) || defined(_AIX)
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 700
#endif
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED
#endif
#else
#define _XOPEN_SOURCE
#endif

@lisongmin

那估计是版本的问题,我这边cat src/fmacros.h结果是
#ifndef __zlog_fmacro_h
#define __zlog_fmacro_h

#undef _LARGEFILE_SOURCE
#define _LARGEFILE_SOURCE

#undef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64

#endif

@lisongmin

应该是没有更新到最新代码导致的。
更新到最新版就没问题了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.