aywfelix / Kafka-cpp

利用开源库librdkafka, 写了一个kafka 测试例子
4 stars 0 forks source link

librdkafka 库是 2.1.1版本吗? #2

Open apachexc opened 1 year ago

apachexc commented 1 year ago

代码有内存有异常,在librdkafka2.1.1,windows c++ 环境下。 linux下正常

aywfelix commented 1 year ago

我都是Linux环境开发,没有在Windows环境测试过,建议你使用最新的库版本

---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2023年05月30日 17:34 | | 收件人 | @.> | | 抄送至 | @.***> | | 主题 | [aywfelix/Kafka-cpp] librdkafka 库是 2.1.1版本吗? (Issue #2) |

代码有内存有异常,在librdkafka2.1.1,windows c++ 环境下。 linux下正常

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

apachexc commented 1 year ago

我用的是最新的库。 linux 下的java , c++ 都没问题了,
就是 windows下报错。

apachexc commented 1 year ago

bool KafkaProducer::Init(const std::string& host, const int port, bool async, const int maxsize) { m_run = true; m_conf = std::shared_ptr(RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL)); m_tconf = std::shared_ptr(RdKafka::Conf::create(RdKafka::Conf::CONF_TOPIC)); if (m_conf == nullptr || m_tconf == nullptr) { m_run = false; return m_run; } std::string errstr; std::string broker(host); broker.append(":").append(std::to_string(port)); m_conf->set("bootstrap.servers", broker, errstr); if (async) { m_conf->set("producer.type", "async", errstr); m_conf->set("queue.buffering.max.messages", std::to_string(maxsize).c_str(), errstr); } else { m_conf->set("producer.type", "sync", errstr); }

m_deliverycb = std::shared_ptr<DeliveryReportCB>(new DeliveryReportCB);
m_eventcb = std::shared_ptr<EventCB>(new EventCB);
m_conf->set("event_cb", m_eventcb.get(), errstr);
m_conf->set("dr_cb", m_deliverycb.get(), errstr);

m_producer = std::shared_ptr<RdKafka::Producer>(RdKafka::Producer::create(m_conf.get(), errstr));
if (m_producer == nullptr)
{
    m_run = false;
    return m_run;
}

return m_run;

初始化后,就报错了。 你的微信是多少,或者QQ,方便加一下吗

apachexc commented 1 year ago

m_conf 指针,无可用信息,未为librdkafak.dll加载任何符号。 VS2017 + windows +c++ +librdkafka2.1.1