我正在尝试为Jetson Nano构建一个包含log4c的项目。 log4c依赖于expat。 expat有一个CMakeLists.txt文件,可与CMake完美配合。我在告诉log4c expat的构建输出在哪里居住以完成链接阶段时遇到麻烦。
我的主要CMakeLists.txt文件执行以下操作:
add_subdirectory(dependencies/libexpat/expat)
add_subdirectory(dependencies/libuuid-1.0.3)
add_subdirectory(dependencies/log4c-1.2.4)
expat构建没有问题。下面列出了我的log4c CMakeLists.txt文件:
# ------------------------------------------------------- MINIMUM CMAKE VERSION
cmake_minimum_required(VERSION 3.10)
include(ExternalProject)
# ---------------------------------------------------------------- PROJECT NAME
set(THIS log4c)
# ------------------------------------------------------------ EXTERNAL PROJECT
if("${BUILD_PLATFORM}" STREQUAL "nano")
set(HOST "--host=aarch64-linux-gnu")
endif()
file(GLOB_RECURSE SRC_FILES
${CMAKE_CURRENT_LIST_DIR}/*
)
file(TOUCH ${SRC_FILES})
ExternalProject_Add(${THIS}_build
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
CONFIGURE_COMMAND ${CMAKE_CURRENT_LIST_DIR}/configure --prefix=${CMAKE_INSTALL_PREFIX}/usr ${HOST}
BUILD_COMMAND make
DEPENDS expat)
#add_dependencies(${THIS}_build expat)
# --------------------------------------------------------------------- LIBRARY
add_library(${THIS} INTERFACE)
target_link_libraries(${THIS} INTERFACE ${CMAKE_INSTALL_PREFIX}/usr/lib/liblog4c.so)
target_include_directories(${THIS} INTERFACE ${CMAKE_INSTALL_PREFIX}/usr/include)
log4c可以正确配置和构建,但是无法链接以下错误消息:
home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src/log4c/rollingpolicy_type_sizewin.c: In function 'sizewin_rollover':
/home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src/log4c/rollingpolicy_type_sizewin.c:116:14: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'void *' [-Wformat=]
sd_error("rollingpolicy '%s' not yet configured (logdir,prefix etc.)",
^
/home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src/log4c/rollingpolicy_type_sizewin.c: In function 'sizewin_init':
/home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src/log4c/rollingpolicy_type_sizewin.c:227:12: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long int' [-Wformat=]
sd_debug("last index '%d'", swup->sw_last_index);
^
libtool: compile: aarch64-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I/home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src/log4c -I../../src -I/home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src -DLOG4C_RCPATH=\"/home/nlbutts/maza/vision2000/build/nano/staging/usr/etc\" -g -O2 -Wall -MT rollingpolicy_type_sizewin.lo -MD -MP -MF .deps/rollingpolicy_type_sizewin.Tpo -c /home/nlbutts/maza/vision2000/dependencies/log4c-1.2.4/src/log4c/rollingpolicy_type_sizewin.c -o rollingpolicy_type_sizewin.o >/dev/null 2>&1
libtool: link: aarch64-linux-gnu-gcc -shared -fPIC -DPIC .libs/rc.o .libs/init.o .libs/appender_type_stream.o .libs/appender_type_stream2.o .libs/appender_type_syslog.o .libs/layout_type_basic.o .libs/layout_type_dated.o .libs/layout_type_dated_local.o .libs/layout_type_basic_r.o .libs/layout_type_dated_r.o .libs/layout_type_dated_local_r.o .libs/version.o .libs/logging_event.o .libs/priority.o .libs/appender.o .libs/layout.o .libs/category.o .libs/appender_type_rollingfile.o .libs/rollingpolicy.o .libs/rollingpolicy_type_sizewin.o -Wl,--whole-archive ../sd/.libs/liblog4c_sd.a -Wl,--no-whole-archive -lexpat -lpthread -O2 -Wl,-soname -Wl,liblog4c.so.3 -o .libs/liblog4c.so.3.3.1
/usr/lib/gcc-cross/aarch64-linux-gnu/5/../../../../aarch64-linux-gnu/bin/ld: cannot find -lexpat
collect2: error: ld returned 1 exit status
Makefile:480: recipe for target 'liblog4c.la' failed
make[7]: *** [liblog4c.la] Error 1
Makefile:436: recipe for target 'all-recursive' failed
make[6]: *** [all-recursive] Error 1
Makefile:353: recipe for target 'all' failed
make[5]: *** [all] Error 2
Makefile:602: recipe for target 'all-recursive' failed
make[4]: *** [all-recursive] Error 1
Makefile:399: recipe for target 'all' failed
make[3]: *** [all] Error 2
dependencies/log4c-1.2.4/CMakeFiles/log4c_build.dir/build.make:111: recipe for target 'dependencies/log4c-1.2.4/log4c_build-prefix/src/log4c_build-stamp/log4c_build-build' failed
make[2]: *** [dependencies/log4c-1.2.4/log4c_build-prefix/src/log4c_build-stamp/log4c_build-build] Error 2
CMakeFiles/Makefile2:395: recipe for target 'dependencies/log4c-1.2.4/CMakeFiles/log4c_build.dir/all' failed
make[1]: *** [dependencies/log4c-1.2.4/CMakeFiles/log4c_build.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
如何告诉log4c expat的构建位置。