0
我正在將我的gmake構建轉換爲cmake構建。該應用程序使用gmake可以很好地構建,但是當我使用cmake時,出現以下錯誤。 以下是gmake和cmake文件。cmake產生錯誤:「stat64'的衝突類型」
父Makefile文件
CC := gcc
CFLAGS := -g -w -m32
INC_DIR := ../includes
OBJ_DIR := ../objects
BIN_DIR := ../bin
孩子的Makefile
include ../../Makefile
SHR_FX := ../$(OBJ_DIR)/shrfx.o
SHRXML := ../$(OBJ_DIR)/shrxml.o
TMP_BIN_DIR = ../$(BIN_DIR)
TMP_INC_DIR = ../$(INC_DIR)
EXECUTABLES := common flogmon
all: $(EXECUTABLES)
%: %.c OAhelper.c OAhelper.h $(SHR_FX) $(TMP_INC_DIR)
@-rm -f [email protected] ## QUIET (@). CONTINUE IF FILE NOT FOUND (-)
$(CC) $(CFLAGS) -I $(TMP_INC_DIR) $(LDLIBPATHFLAGS) -o [email protected] [email protected] OAhelper.c $(SHR_FX)
@-chmod 0775 [email protected] #SH(@),CONT(-). Allow others to do it.
mv [email protected] $(TMP_BIN_DIR)
父CMakeList.txt
cmake_minimum_required(VERSION 2.8.9)
project(program)
set(CMAKE_BUILD_TYPE Release)
set (EXECUTABLE_OUTPUT_PATH "/home/user/workspace/program")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -w -m32")
add_subdirectory(opaid/opaid_helper)
孩子CMakeList.txt
cmake_minimum_required(VERSION 2.8.9)
#Bring the headers
include_directories(../../includes)
set (PROJ_LIST "common;flogmon")
message (STATUS "CFLAGS : " ${CMAKE_C_FLAGS})
foreach (PROJ ${PROJ_LIST})
project(${PROJ})
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath=${EXECUTABLE_OUTPUT_PATH}:${EXECUTABLE_OUTPUT_PATH}../RSA/cryptocme3001/library/lib")
add_executable(${PROJ} ${PROJ}.c OAhelper.c)
target_link_libraries(${PROJ} LINK_PUBLIC shrfx)
install(TARGETS ${PROJ} DESTINATION ${EXECUTABLE_OUTPUT_PATH})
endforeach()
錯誤
Building C object /CMakeFiles/common.dir/common.c.o
In file included from /usr/include/features.h:375:0,
from /usr/include/sys/poll.h:22,
from /usr/include/poll.h:1,
from /home/user/workspace/program/src/common.c:26:
/usr/include/sys/stat.h:503:1: error: conflicting types for ‘stat64’
__NTH (stat64 (const char *__path, struct stat64 *__statbuf))
^
In file included from
/home/user/workspace/program/src/../../includes/fxgen.h:205:0,
from /home/user/workspace/program/src/../../includes/fx.h:286,
from /home/user/workspace/program/src/common.c:39:
/usr/include/sys/stat.h:229:12: note: previous declaration of ‘stat64’
was here extern int stat64 (const char *__restrict __file,
如果我期待在/usr/include/sys/stat.h ...
503
# if defined __USE_LARGEFILE64 \
&& (! defined __USE_FILE_OFFSET64 \
|| (defined __REDIRECT_NTH && defined __OPTIMIZE__))
__extern_inline int
__NTH (stat64 (const char *__path, struct stat64 *__statbuf))
{
return __xstat64 (_STAT_VER, __path, __statbuf);
}
229
#ifdef __USE_LARGEFILE64
extern int stat64 (const char *__restrict __file,
struct stat64 *__restrict __buf) __THROW __nonnull ((1, 2));
extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
#endif
運行'make VERBOSE = 1'並檢查gmake調用中命令行之間的區別。 – Tsyvarev
看起來好像你錯過了最後一個錯誤行的最後一部分。但是,它可能不是一個大問題 - 它可能是'struct stat64 * __ statbuf);'或者其他缺失的東西。你可能需要追蹤'common.c'或'fx.h'和'fxgen.h'頭文件所做的事情,以使'stat64()'的兩個不兼容的聲明可見。問題可能出現在'common.c'之前的另一個頭文件中,但我會從這些頭文件開始。 (使用'gcc -H'列出所包含的所有文件,這可能也有幫助。) –
請注意,CMake不是[g] make的模擬;它更符合Autotools的要求。事實上,CMake爲您生成的makefiles會在所有處理舊makefile的平臺上由gmake(== GNU make)處理。 –