'OpenVAS libgvm_util.so: undefined reference to `MQTTClient_`

Have some troubles in compiling from source https://github.com/greenbone/openvas.git cmake was done successfully, but make failed with:

/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTClient_connect5'
/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTClient_publishMessage5'
/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTClient_freeMessage'
/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTClient_free'
/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTClient_createWithOptions'
/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTClient_waitForCompletion'
/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTProperties_free'
/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTClient_receive'
/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTClient_disconnect5'
/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTClient_subscribe5'
/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTClient_strerror'
/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTClient_destroy'
/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTClient_unsubscribe'
/usr/bin/ld: /opt/gvm/lib/libgvm_util.so: undefined reference to `MQTTResponse_free'
collect2: error: ld returned 1 exit status
make[2]: *** [nasl/CMakeFiles/openvas-nasl-lint.dir/build.make:86: nasl/openvas-nasl-lint] Error 1
make[1]: *** [CMakeFiles/Makefile2:284: nasl/CMakeFiles/openvas-nasl-lint.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

Have installed from source Paho_MQTT_C_Client and have in /usr/local/lib/ all the libpaho-mqtt3 libs:

libpaho-mqtt3a.so      libpaho-mqtt3as.so.1    libpaho-mqtt3c.so.1.3   python3.8
libpaho-mqtt3a.so.1    libpaho-mqtt3as.so.1.3  libpaho-mqtt3cs.so
libpaho-mqtt3a.so.1.3  libpaho-mqtt3c.so       libpaho-mqtt3cs.so.1
libpaho-mqtt3as.so     libpaho-mqtt3c.so.1     libpaho-mqtt3cs.so.1.3

nm libpaho-mqtt3c.so:

0000000000016b9d T MQTTClient_connect5
000000000001828c T MQTTClient_publishMessage5
00000000000152f4 T MQTTClient_freeMessage
000000000001536a T MQTTClient_free
00000000000187eb T MQTTClient_createWithOptions
0000000000018465 T MQTTClient_waitForCompletion
000000000001301b T MQTTProperties_free
00000000000171f9 T MQTTClient_receive
0000000000016c60 T MQTTClient_disconnect5
0000000000017cd5 T MQTTClient_subscribe5
0000000000018be9 T MQTTClient_strerror
00000000000150dc T MQTTClient_destroy
000000000001783f T MQTTClient_unsubscribe
00000000000153b7 T MQTTResponse_free

Here the CMakeLists:

cmake_minimum_required (VERSION 3.0)

message ("-- Configuring the Scanner...")

# VERSION: Always include major, minor and patch level.
project (openvas
  VERSION 21.10.0
  LANGUAGES C)

if (POLICY CMP0005)
  cmake_policy (SET CMP0005 NEW)
endif (POLICY CMP0005)

SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

if (NOT CMAKE_BUILD_TYPE)
  set (CMAKE_BUILD_TYPE Debug)
endif (NOT CMAKE_BUILD_TYPE)

OPTION (ENABLE_COVERAGE "Enable support for coverage analysis" OFF)

## Retrieve git revision (at configure time)
include (GetGit)

if (NOT CMAKE_BUILD_TYPE MATCHES "Release")
  if (EXISTS "${CMAKE_SOURCE_DIR}/.git/")
    if (GIT_FOUND)
      Git_GET_REVISION(${CMAKE_SOURCE_DIR} ProjectRevision)
      set (GIT_REVISION "~git-${ProjectRevision}")
    endif (GIT_FOUND)
  endif (EXISTS "${CMAKE_SOURCE_DIR}/.git/")
endif (NOT CMAKE_BUILD_TYPE MATCHES "Release")

## make format
message (STATUS "Looking for clang-format...")
find_program (CLANG_FORMAT clang-format)
if (CLANG_FORMAT)
  message (STATUS "Looking for clang-format... ${CLANG_FORMAT}")
  add_custom_target(format COMMAND ${CLANG_FORMAT} "-i" "./src/*.c" "./misc/*.c"
                    "./nasl/*.c" "./src/*.h" "./misc/*.h" "./nasl/*.h"
                    WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
else (CLANG_FORMAT)
  message (STATUS "clang-format not found...")
endif (CLANG_FORMAT)

# Set dev version if this is a development version and not a full release,
# unset (put value 0 or delete line) before a full release and reset after.
set (PROJECT_DEV_VERSION 1)

# If PROJECT_DEV_VERSION is set, the version string will be set to:
#   "major.minor.patch~dev${PROJECT_DEV_VERSION}${GIT_REVISION}"
# If PROJECT_DEV_VERSION is NOT set, the version string will be set to:
#   "major.minor.patch${GIT_REVISION}"
# For CMAKE_BUILD_TYPE "Release" the git revision will be empty.
if (PROJECT_DEV_VERSION)
  set (PROJECT_VERSION_SUFFIX "~dev${PROJECT_DEV_VERSION}")
endif (PROJECT_DEV_VERSION)

set (PROJECT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}${PROJECT_VERSION_SUFFIX}${GIT_REVISION}")

## CPack configuration

set (CPACK_CMAKE_GENERATOR "Unix Makefiles")
set (CPACK_GENERATOR "TGZ")
set (CPACK_INSTALL_CMAKE_PROJECTS ".;openvas;ALL;/")
set (CPACK_MODULE_PATH "")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set (CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
set (CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/README.md")
set (CPACK_SOURCE_GENERATOR "TGZ")
set (CPACK_SOURCE_TOPLEVEL_TAG "")
set (CPACK_SYSTEM_NAME "")
set (CPACK_TOPLEVEL_TAG "")

set (CPACK_PACKAGE_VERSION "${PROJECT_VERSION_STRING}${PROJECT_VERSION_GIT}")

set (CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
set (CPACK_PACKAGE_VENDOR "The OpenVAS Project")
set (CPACK_SOURCE_IGNORE_FILES
"${CMAKE_BINARY_DIR}"
"/.git/"
"swp$"
"nasl/nasl_grammar.tab.c"
"nasl/nasl_grammar.tab.h"
"nasl/nasl_grammar.output"
)

include (CPack)

## Variables

if (SYSCONF_INSTALL_DIR)
  set (SYSCONFDIR "${SYSCONF_INSTALL_DIR}")
endif (SYSCONF_INSTALL_DIR)

if (NOT SYSCONFDIR)
  set (SYSCONFDIR "/etc")
endif (NOT SYSCONFDIR)

if (NOT EXEC_PREFIX)
  set (EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}")
endif (NOT EXEC_PREFIX)

if (NOT BINDIR)
  set (BINDIR "${EXEC_PREFIX}/bin")
endif (NOT BINDIR)

if (NOT SBINDIR)
  set (SBINDIR "${EXEC_PREFIX}/sbin")
endif (NOT SBINDIR)

if (NOT LIBDIR)
  set (_DEFAULT_LIBRARY_INSTALL_DIR lib)
  if (EXISTS "${EXEC_PREFIX}/lib32/" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
    set (_DEFAULT_LIBRARY_INSTALL_DIR lib32)
  endif (EXISTS "${EXEC_PREFIX}/lib32/" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
  if (EXISTS "${CMAKE_INSTALL_PREFIX}/lib64/" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
    set (_DEFAULT_LIBRARY_INSTALL_DIR lib64)
  endif (EXISTS "${CMAKE_INSTALL_PREFIX}/lib64/" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
  set( LIBRARY_INSTALL_DIR "${_DEFAULT_LIBRARY_INSTALL_DIR}")
  set (LIBDIR "${EXEC_PREFIX}/${LIBRARY_INSTALL_DIR}")
  message ("Set LIBDIR to ${LIBDIR}")
endif (NOT LIBDIR)

if (NOT LOCALSTATEDIR)
  set (LOCALSTATEDIR "/var")
endif (NOT LOCALSTATEDIR)

if (NOT DATADIR)
  set (DATADIR "${CMAKE_INSTALL_PREFIX}/share")
endif (NOT DATADIR)

if (NOT OPENVAS_RUN_DIR)
  set (OPENVAS_RUN_DIR "/run/ospd")
endif (NOT OPENVAS_RUN_DIR)

set (OPENVAS_DATA_DIR    "${DATADIR}/openvas")
set (OPENVAS_STATE_DIR   "${LOCALSTATEDIR}/lib/openvas")

if (NOT OPENVAS_FEED_LOCK_PATH)
  set (OPENVAS_FEED_LOCK_PATH "${OPENVAS_STATE_DIR}/feed-update.lock")
endif (NOT OPENVAS_FEED_LOCK_PATH)
add_definitions (-DOPENVAS_FEED_LOCK_PATH="${OPENVAS_FEED_LOCK_PATH}")

if (NOT GVM_LOG_DIR)
    set (GVM_LOG_DIR         "${LOCALSTATEDIR}/log/gvm")
endif (NOT GVM_LOG_DIR)
set (OPENVAS_SYSCONF_DIR "${SYSCONFDIR}/openvas")
set (GVM_SYSCONF_DIR     "${SYSCONFDIR}/gvm")

if (NOT OPENVAS_NVT_DIR)
  set (OPENVAS_NVT_DIR     "${OPENVAS_STATE_DIR}/plugins")
endif (NOT OPENVAS_NVT_DIR)

if (NOT GVM_ACCESS_KEY_DIR)
    set (GVM_ACCESS_KEY_DIR "${GVM_SYSCONF_DIR}")
endif (NOT GVM_ACCESS_KEY_DIR)

if (NOT OPENVAS_GPG_BASE_DIR)
    set (OPENVAS_GPG_BASE_DIR "${OPENVAS_SYSCONF_DIR}")
endif (NOT OPENVAS_GPG_BASE_DIR)

set (OPENVAS_LIB_INSTALL_DIR     "${LIBDIR}")

set (OPENVAS_CONF     "${OPENVAS_SYSCONF_DIR}/openvas.conf")

set (NVT_TIMEOUT "320")
set (SCANNER_NVT_TIMEOUT "36000")

message ("-- Install prefix: ${CMAKE_INSTALL_PREFIX}")

## Version

set (OPENVAS_VERSION "${PROJECT_VERSION_STRING}")

# Configure Doxyfile with version number
configure_file (doc/Doxyfile.in doc/Doxyfile @ONLY)
configure_file (doc/Doxyfile_full.in doc/Doxyfile_full @ONLY)
configure_file (doc/Doxyfile_xml.in doc/Doxyfile_xml @ONLY)
configure_file (doc/openvas.8.in doc/openvas.8 @ONLY)
configure_file (VERSION.in VERSION @ONLY)
configure_file (tools/greenbone-nvt-sync.in tools/greenbone-nvt-sync @ONLY)
configure_file (src/openvas_log_conf.cmake_in src/openvas_log.conf)

## Testing

enable_testing ()

add_custom_target (tests
                   DEPENDS attack-test pcap-test)

## Program

if (ENABLE_COVERAGE)
  set (COVERAGE_FLAGS "--coverage")
endif (ENABLE_COVERAGE)

set (HARDENING_FLAGS            "-Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -fstack-protector")
set (LINKER_HARDENING_FLAGS     "-Wl,-z,relro -Wl,-z,now")
# The "-D_FILE_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1" is necessary for GPGME!
set (GPGME_C_FLAGS              "-D_FILE_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1")

set (CMAKE_C_FLAGS_RELEASE      "${CMAKE_C_FLAGS_RELEASE} ${HARDENING_FLAGS}")
set (CMAKE_C_FLAGS_DEBUG        "${CMAKE_C_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
set (CMAKE_C_FLAGS              "${CMAKE_C_FLAGS} ${GPGME_C_FLAGS} -Wall -D_BSD_SOURCE -D_ISOC99_SOURCE -D_SVID_SOURCE -D_DEFAULT_SOURCE")

if (NOT SKIP_SRC)
  add_subdirectory (misc)
  add_subdirectory (nasl)
  add_subdirectory (src)
endif (NOT SKIP_SRC)

## Documentation

add_subdirectory (doc)


## Tests

enable_testing ()

## End

Any clue how to sort it out?



Solution 1:[1]

You need to build gvm-libs from main branch too with libpaho support. But building from main branch is strongly unrecommended. Main branches are development branches an can break every time. Please use the stable branches instead.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Björn Ricks