Getting /libgcc_s.so.1: version ‘GCC_3.4’ does not exist: error while testing a c++ program using librdkafka library

  apache-kafka, c++

I am compiling the below sample C++ kafka producer program using librdkafka library in Solaris OS and getting error while linking:

Sample program:

#include <iostream>
#include "rdkafkacpp.h"


int static producer_1()
{
    std::string brokers = "127.0.0.1";
    std::string errstr;
    std::string topic_str = "linli";
    std::string mode;
    std::string debug;
    int32_t partition = RdKafka::Topic::PARTITION_UA;
    int64_t start_offset = RdKafka::Topic::OFFSET_BEGINNING;
    bool do_conf_dump = false;
    int opt;
    // MyHashPartitionerCb hash_partitioner;
    int use_ccb = 0;

    /*
    * Create configuration objects
    */
    RdKafka::Conf *conf = RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL);
    RdKafka::Conf *tconf = RdKafka::Conf::create(RdKafka::Conf::CONF_TOPIC);

    conf->set("metadata.broker.list", brokers, errstr);

    RdKafka::Producer *producer = RdKafka::Producer::create(conf, errstr);
    if (!producer) {
        std::cerr << "Failed to create producer: " << errstr << std::endl;
        exit(1);
    }

    std::cout << "% Created producer " << producer->name() << std::endl;

    /*
    * Create topic handle.
    */
    RdKafka::Topic *topic = NULL;
    if (!topic_str.empty()) {
        topic = RdKafka::Topic::create(producer, topic_str, tconf, errstr);
        if (!topic) {
            std::cerr << "Failed to create topic: " << errstr << std::endl;
            exit(1);
        }
    }

    RdKafka::ErrorCode resp = producer->produce(topic, partition,
        RdKafka::Producer::RK_MSG_COPY /* Copy payload */,
        const_cast<char *>("hello worlf"), 11,
        NULL, NULL);

    delete topic;
    delete producer;
    return 0;
}


int static producer_2()
{
    std::string brokers = "127.0.0.1";
    std::string errstr;
    std::string topic_str = "linli";
    std::string mode;
    std::string debug;
    int32_t partition = RdKafka::Topic::PARTITION_UA;
    int64_t start_offset = RdKafka::Topic::OFFSET_BEGINNING;
    bool do_conf_dump = false;
    int opt;
    // MyHashPartitionerCb hash_partitioner;
    int use_ccb = 0;

    RdKafka::Conf *conf = RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL);
    RdKafka::Conf *tconf = RdKafka::Conf::create(RdKafka::Conf::CONF_TOPIC);

    conf->set("metadata.broker.list", brokers, errstr);

    RdKafka::Producer *producer = RdKafka::Producer::create(conf, errstr);
    if (!producer) {
        std::cerr << "Failed to create producer: " << errstr << std::endl;
        exit(1);
    }

    std::cout << "% Created producer " << producer->name() << std::endl;

    RdKafka::ErrorCode resp = producer->produce(topic_str, partition,
        RdKafka::Producer::RK_MSG_COPY /* Copy payload */,
        (void *)"hi", 2,
        NULL, 0, 0, NULL);



    std::string errs(RdKafka::err2str(resp));
    std::cout << errs << std::endl;
    //producer->poll(0);


    delete producer;

    return 0;
}


int main()
{

    producer_2();

    return 0;
}

Steps to recreate the problem:

Apache kafka installed: kafka_2.13-3.0.0
C++ API library for kafka: librdkafka++.so.1

Compile using CC as shown below:

CC KafkaProducerConsumer.cc librdkafka++.so.1

Code is getting compiled success but while linking it is returning the below errors:

"rdkafkacpp.h", line 2139: Warning: Identifier expected instead of "}".
1 Warning(s) detected.
ld: fatal: file /p2k/L10.93A/bld/bin/libgcc_s.so.1: version ‘GCC_3.3’ does not exist:
required by file /opt/csw/lib/sparcv8/libstdc++.so.6
ld: fatal: file /p2k/L10.93A/bld/bin/libgcc_s.so.1: version ‘GCC_3.4’ does not exist:
required by file /opt/csw/lib/sparcv8/libstdc++.so.6
ld: fatal: file /p2k/L10.93A/bld/bin/libgcc_s.so.1: version ‘GCC_4.2.0’ does not exist:
required by file /opt/csw/lib/sparcv8/libstdc++.so.6
ld: fatal: file /p2k/L10.93A/bld/bin/libgcc_s.so.1: version ‘GCC_3.4’ does not exist:
required by file /opt/csw/lib/sparcv8/librdkafka.so.1
ld: fatal: file /p2k/L10.93A/bld/bin/libgcc_s.so.1: version ‘GCC_4.3.0’ does not exist:
required by file /opt/csw/lib/sparcv8/librdkafka.so.1
ld: fatal: file /p2k/L10.93A/bld/bin/libgcc_s.so.1: version ‘GCC_3.4’ does not exist:
required by file /opt/csw/lib/sparcv8/liblz4.so.1
ld: fatal: file /p2k/L10.93A/bld/bin/libgcc_s.so.1: version ‘GCC_4.3.0’ does not exist:
required by file /opt/csw/lib/sparcv8/liblz4.so.1
ld: fatal: file /p2k/L10.93A/bld/bin/libgcc_s.so.1: version ‘GCC_3.4’ does not exist:
required by file /opt/csw/lib/sparcv8/libzstd.so.1
ld: fatal: file /p2k/L10.93A/bld/bin/libgcc_s.so.1: version ‘GCC_4.3.0’ does not exist:
required by file /opt/csw/lib/sparcv8/libzstd.so.1
ld: fatal: file processing errors. No output written to a.out

I am not sure what is causing the problem?

Can you please help me what can be done to fix the above errors?

Source: Windows Questions C++

LEAVE A COMMENT