1

我正在尝试为 Jetson Nano 构建一个包含 log4c 的项目。log4c 依赖于外籍人士。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 是在哪里构建的。

4

0 回答 0