undefined reference to `sd_listen_fds

Viewed 27

I have an undefined reference to sd_listen_fds'`. I am trying to add systemd as a depenedency to resolve this. Doesn't seem to do the trick.

I referenced this to add systemd https://github.com/ximion/limba/blob/master/data/cmake/systemdservice.cmake

Log data follows:
| DEBUG: Executing python function externalsrc_compile_prefunc
| NOTE: example-tiles: compiling from external source tree /home/src/example-tiles/tile-server
| DEBUG: Python function externalsrc_compile_prefunc finished
| DEBUG: Executing shell function do_compile
| NOTE: VERBOSE=1 cmake --build /work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/example-tiles-1.0/ --target all --
| [1/1] : && /work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0=/usr/src/debug/example-tiles/1.0-r0                      -fdebug-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0=/usr/src/debug/example-tiles/1.0-r0                      -fdebug-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot=                      -fdebug-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot-native=  -fasynchronous-unwind-tables -fvisibility-inlines-hidden  -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot  -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0=/usr/src/debug/example-tiles/1.0-r0                      -fdebug-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0=/usr/src/debug/example-tiles/1.0-r0                      -fdebug-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot=                      -fdebug-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot-native=  -fasynchronous-unwind-tables -fvisibility-inlines-hidden  -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now  -rdynamic CMakeFiles/example-tile-server.dir/main.cpp.o CMakeFiles/example-tile-server.dir/tileprovider.cpp.o -o example-tile-server  /work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot/usr/lib/libboost_system.so.1.75.0  /work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot/usr/lib/libboost_thread.so.1.75.0  /work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot/usr/lib/libboost_filesystem.so.1.75.0  -lpthread  -lsqlite3  -lpthread && :
| FAILED: example-tile-server
| : && /work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0=/usr/src/debug/example-tiles/1.0-r0                      -fdebug-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0=/usr/src/debug/example-tiles/1.0-r0                      -fdebug-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot=                      -fdebug-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot-native=  -fasynchronous-unwind-tables -fvisibility-inlines-hidden  -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot  -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0=/usr/src/debug/example-tiles/1.0-r0                      -fdebug-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0=/usr/src/debug/example-tiles/1.0-r0                      -fdebug-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot=                      -fdebug-prefix-map=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot-native=  -fasynchronous-unwind-tables -fvisibility-inlines-hidden  -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security  --sysroot=/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now  -rdynamic CMakeFiles/example-tile-server.dir/main.cpp.o CMakeFiles/example-tile-server.dir/tileprovider.cpp.o -o example-tile-server  /work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot/usr/lib/libboost_system.so.1.75.0  /work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot/usr/lib/libboost_thread.so.1.75.0  /work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot/usr/lib/libboost_filesystem.so.1.75.0  -lpthread  -lsqlite3  -lpthread && :
| /work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/10.3.0/ld: CMakeFiles/example-tile-server.dir/main.cpp.o: in function `SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::execution::any_executor<boost::asio::execution::context_as_t<boost::asio::execution_context&>, boost::asio::execution::detail::blocking::never_t<0>, boost::asio::execution::prefer_only<boost::asio::execution::detail::blocking::possibly_t<0> >, boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::tracked_t<0> >, boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::untracked_t<0> >, boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::fork_t<0> >, boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::continuation_t<0> > > > >::start(std::function<void (unsigned short)> const&)':
| /home/src/example-tiles/tile-server/../Simple-Web-Server/server_http.hpp:429: undefined reference to `sd_listen_fds'
| collect2: error: ld returned 1 exit status
| ninja: build stopped: subcommand failed.
| WARNING: exit code 1 from a shell command.
| ERROR: ExecutionError('/work/kodiak/build/tmp/work/cortexa9t2hf-neon-poky-linux-gnueabi/example-tiles/1.0-r0/temp/run.do_compile.364688', 1, None, None)
ERROR: Task (/work/kodiak/build/../sources/meta-example/recipes-example/example-tiles/example-tiles.bb:do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 7384 tasks of which 7383 didn't need to be rerun and 1 failed.

  cmake_minimum_required(VERSION 3.0)

project(Simple-Web-Server)

include(GNUInstallDirs)


option(USE_STANDALONE_ASIO "set ON to use standalone Asio instead of Boost.Asio" OFF)
if(CMAKE_SOURCE_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
    option(BUILD_TESTING "set ON to build library tests" ON)
else()
    option(BUILD_TESTING "set ON to build library tests" OFF)
endif()
option(BUILD_FUZZING "set ON to build library fuzzers" OFF)
option(USE_OPENSSL "set OFF to build without OpenSSL" ON)

add_library(simple-web-server INTERFACE)

target_include_directories(simple-web-server INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

find_package(PkgConfig)
pkg_check_modules(SYSTEMD IMPORTED_TARGET systemd)

find_package(Threads REQUIRED)

target_link_libraries(simple-web-server INTERFACE PkgConfig::SYSTEMD)
target_link_libraries(simple-web-server INTERFACE ${CMAKE_THREAD_LIBS_INIT})

# TODO 2020 when Debian Jessie LTS ends:
# Remove Boost system, thread, regex components; use Boost::<component> aliases; remove Boost target_include_directories
if(USE_STANDALONE_ASIO)
    message("USING STANDALONE")
    target_compile_definitions(simple-web-server INTERFACE ASIO_STANDALONE)
    find_path(ASIO_PATH asio.hpp)
    if(NOT ASIO_PATH)
        message(FATAL_ERROR "Standalone Asio not found")
    else()
        target_include_directories(simple-web-server INTERFACE ${ASIO_PATH})
    endif()
else()
    message("NOT USING STANDALONE")
    find_package(Boost 1.53.0 COMPONENTS system thread REQUIRED)
    target_link_libraries(simple-web-server INTERFACE ${Boost_LIBRARIES})
    target_include_directories(simple-web-server INTERFACE ${Boost_INCLUDE_DIR})
    if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
        target_compile_definitions(simple-web-server INTERFACE USE_BOOST_REGEX)
        find_package(Boost 1.53.0 COMPONENTS regex REQUIRED)
        target_link_libraries(simple-web-server INTERFACE ${Boost_LIBRARIES})
        target_include_directories(simple-web-server INTERFACE ${Boost_INCLUDE_DIR})
    endif()
endif()
if(WIN32)
    target_link_libraries(simple-web-server INTERFACE ws2_32 wsock32)
endif()

if(APPLE)
    set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
endif()
if(USE_OPENSSL)
    find_package(OpenSSL)
endif()
if(OPENSSL_FOUND)
    target_compile_definitions(simple-web-server INTERFACE HAVE_OPENSSL)
    target_link_libraries(simple-web-server INTERFACE ${OPENSSL_LIBRARIES})
    target_include_directories(simple-web-server INTERFACE ${OPENSSL_INCLUDE_DIR})
endif()

# If Simple-Web-Server is not a sub-project:
if(CMAKE_SOURCE_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
    message("NOT A SUB-PROJECT")
    if(NOT MSVC)
        add_compile_options(-std=c++11 -Wall -Wextra)
        if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
            add_compile_options(-Wthread-safety)
        endif()
    else()
        add_compile_options(/W1)
    endif()

    find_package(Boost 1.53.0 COMPONENTS system thread filesystem)
    if(Boost_FOUND)
        add_executable(http_examples http_examples.cpp)
        target_link_libraries(http_examples simple-web-server)
        target_link_libraries(http_examples ${Boost_LIBRARIES})
        target_include_directories(http_examples PRIVATE ${Boost_INCLUDE_DIR})
        if(OPENSSL_FOUND)
            add_executable(https_examples https_examples.cpp)
            target_link_libraries(https_examples simple-web-server)
            target_link_libraries(https_examples ${Boost_LIBRARIES})
            target_include_directories(https_examples PRIVATE ${Boost_INCLUDE_DIR})
        endif()
     endif()

    install(FILES asio_compatibility.hpp server_http.hpp client_http.hpp server_https.hpp client_https.hpp crypto.hpp utility.hpp status_code.hpp mutex.hpp DESTINATION include/simple-web-server)
endif()

if(BUILD_TESTING OR BUILD_FUZZING)
    if(BUILD_TESTING)
        enable_testing()
    endif()
    add_subdirectory(tests)
endif()
0 Answers
Related