Skip to content

Linkage error related to CivetServer #740

Description

@D0zee

Hi guys, trying to compile the project with the library, but getting linkage error:

#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libcivetweb-cpp.a(CivetServer.cpp.o): plugin needed to handle lto object
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libcivetweb-cpp.a(CivetServer.cpp.o): plugin needed to handle lto object
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(exposer.cc.o): in function `prometheus::Exposer::Exposer(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, CivetCallbacks const*)':
#19 109.2 exposer.cc:(.text+0x30): undefined reference to `CivetServer::CivetServer(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, CivetCallbacks const*, void const*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(exposer.cc.o): in function `prometheus::Exposer::GetListeningPorts() const':
#19 109.2 exposer.cc:(.text+0x881): undefined reference to `CivetServer::getListeningPorts()'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(endpoint.cc.o): in function `prometheus::detail::Endpoint::~Endpoint()':
#19 109.2 endpoint.cc:(.text+0x16): undefined reference to `CivetServer::removeHandler(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
#19 109.2 /usr/bin/ld: endpoint.cc:(.text+0x28): undefined reference to `CivetServer::removeAuthHandler(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(endpoint.cc.o): in function `prometheus::detail::Endpoint::RegisterAuth(std::function<bool (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
#19 109.2 endpoint.cc:(.text+0x1ef): undefined reference to `CivetServer::addAuthHandler(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, CivetAuthHandler*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(endpoint.cc.o): in function `prometheus::detail::Endpoint::Endpoint(CivetServer&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
#19 109.2 endpoint.cc:(.text+0x45a): undefined reference to `CivetServer::addHandler(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, CivetHandler*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTIN10prometheus6detail14MetricsHandlerE[_ZTIN10prometheus6detail14MetricsHandlerE]+0x10): undefined reference to `typeinfo for CivetHandler'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTVN10prometheus6detail14MetricsHandlerE[_ZTVN10prometheus6detail14MetricsHandlerE]+0x28): undefined reference to `CivetHandler::handleGet(CivetServer*, mg_connection*, int*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTVN10prometheus6detail14MetricsHandlerE[_ZTVN10prometheus6detail14MetricsHandlerE]+0x30): undefined reference to `CivetHandler::handlePost(CivetServer*, mg_connection*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTVN10prometheus6detail14MetricsHandlerE[_ZTVN10prometheus6detail14MetricsHandlerE]+0x38): undefined reference to `CivetHandler::handlePost(CivetServer*, mg_connection*, int*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTVN10prometheus6detail14MetricsHandlerE[_ZTVN10prometheus6detail14MetricsHandlerE]+0x40): undefined reference to `CivetHandler::handleHead(CivetServer*, mg_connection*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTVN10prometheus6detail14MetricsHandlerE[_ZTVN10prometheus6detail14MetricsHandlerE]+0x48): undefined reference to `CivetHandler::handleHead(CivetServer*, mg_connection*, int*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTVN10prometheus6detail14MetricsHandlerE[_ZTVN10prometheus6detail14MetricsHandlerE]+0x50): undefined reference to `CivetHandler::handlePut(CivetServer*, mg_connection*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTVN10prometheus6detail14MetricsHandlerE[_ZTVN10prometheus6detail14MetricsHandlerE]+0x58): undefined reference to `CivetHandler::handlePut(CivetServer*, mg_connection*, int*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTVN10prometheus6detail14MetricsHandlerE[_ZTVN10prometheus6detail14MetricsHandlerE]+0x60): undefined reference to `CivetHandler::handleDelete(CivetServer*, mg_connection*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTVN10prometheus6detail14MetricsHandlerE[_ZTVN10prometheus6detail14MetricsHandlerE]+0x68): undefined reference to `CivetHandler::handleDelete(CivetServer*, mg_connection*, int*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTVN10prometheus6detail14MetricsHandlerE[_ZTVN10prometheus6detail14MetricsHandlerE]+0x70): undefined reference to `CivetHandler::handleOptions(CivetServer*, mg_connection*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTVN10prometheus6detail14MetricsHandlerE[_ZTVN10prometheus6detail14MetricsHandlerE]+0x78): undefined reference to `CivetHandler::handleOptions(CivetServer*, mg_connection*, int*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTVN10prometheus6detail14MetricsHandlerE[_ZTVN10prometheus6detail14MetricsHandlerE]+0x80): undefined reference to `CivetHandler::handlePatch(CivetServer*, mg_connection*)'
#19 109.2 /usr/bin/ld: vcpkg_installed/x64-linux/lib/libprometheus-cpp-pull.a(handler.cc.o):(.data.rel.ro._ZTVN10prometheus6detail14MetricsHandlerE[_ZTVN10prometheus6detail14MetricsHandlerE]+0x88): undefined reference to `CivetHandler::handlePatch(CivetServer*, mg_connection*, int*)'
#19 109.2 clang: error: linker command failed with exit code 1 (use -v to see invocation)
#19 109.2 ninja: build stopped: subcommand failed.

I use vcpkg where install the latest version and my cmake skeleton looks like:

cmake_minimum_required(VERSION 3.18)

project(Example CXX)

set(CMAKE_CXX_STANDARD 20)
...
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)

set(SOURCES
  ...
)

set(LIBS
  prometheus-cpp::pull
  prometheus-cpp::core
  civetweb::civetweb-cpp
  civetweb::civetweb
)

# === Executable ===
add_executable(example 
    src/main.cpp
    ${SOURCES}
)

target_link_libraries(example PRIVATE ${LIBS})

# Prometheus 
find_package(prometheus-cpp REQUIRED)
find_package(civetweb REQUIRED)

Can you please help me? Tried the described actions from #639, tried to enable/disable LTO via set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE) but nothing helped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions