Skip to content
This repository was archived by the owner on Jun 17, 2026. It is now read-only.
This repository was archived by the owner on Jun 17, 2026. It is now read-only.

If you encounter a linking issue with g++ like this, please use extern "C" #86

Description

@GoingMyWay
CMakeFiles/project_tlinux.dir/include/metric/prometheus.cpp.o: In function `metric::Prometheus::StartHttpServer()':                                                                                                                     
prometheus_producer.cpp:(.text+0x141): undefined reference to `promhttp_start_daemon(unsigned int, unsigned short, int (*)(void*, sockaddr const*, unsigned int), void*)'                                                                                                
CMakeFiles/project_tlinux.dir/include/metric/prometheus_producer.cpp.o: In function `metric::Prometheus::PrometheusProducer(int)':                                                                                                               
prometheus_producer.cpp:(.text+0x1af): undefined reference to `promhttp_start_daemon(unsigned int, unsigned short, int (*)(void*, sockaddr const*, unsigned int), void*)'                                                                                                
prometheus.cpp:(.text+0x1b8): undefined reference to `prom_collector_registry_default_init()'                

If you encounter a linking issue like this, please use extern "C" in this way in you C++ project:

#ifdef __cplusplus
extern "C" {
#endif

#include "promhttp.h"  // Include the original C header
#include "prom.h"      // Include the original C header

#ifdef __cplusplus
}
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions