添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I did the following steps on my Terminal- Ubuntu 16.0.4 LTS to install librdkafka:-

1)wget -qO - https://packages.confluent.io/deb/5.2/archive.key | sudo apt-key add -
(Install the Confluent public key. )
2)sudo add-apt-repository "deb [arch=amd64] https://packages.confluent.io/deb/5.2 stable main"
(Add the repository to your /etc/apt/sources.list by running this command)
3)sudo apt-get update && sudo apt-get install confluent-platform-2.12
4)sudo apt-get update && sudo apt-get install confluent-community-2.12
(Update apt-get and install the entire Confluent Platform platform)

5)sudo apt install librdkafka-dev

Then I wrote the following code called abc1.cpp(which is located on Desktop):-

#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <json/json.h>
#include <librdkafka/rdkafkacpp.h>
using namespace std;
void sendKafkaEvent(RdKafka::Producer* producer, std::string out)
cout<<"hvg"<<endl;
cout<<out;
RdKafka::Headers *headers = RdKafka::Headers::create();
headers->add("my header", "header value");
headers->add("other header", "yes");
//Json::StreamWriterBuilder builder;
//builder.settings_["indentation"] = "";
//std::string out = Json::writeString(builder, detectionEvent);
//cout << " out value " << out << endl;
RdKafka::ErrorCode resp =
 producer->produce("SJ", RdKafka::Topic::PARTITION_UA,
  RdKafka::Producer::RK_MSG_COPY /* Copy payload */,
  /* Value */
  const_cast<char *>(out.c_str()), out.size(),
  /* Key */
  NULL, 0,
  /* Timestamp (defaults to now) */
  /* Message headers, if any */
  headers,
  /* Per-message opaque value passed to
   * delivery report */
  NULL);
cout<<resp<<endl;
int main()
 * Create configuration objects
cout<<"Test1:";
std::string brokers = "192.168.1.4"; //Kafka Server or consumer ip address here"192.168.100.1";
std::string errstr;
RdKafka::Conf *conf = RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL);
RdKafka::Conf *tconf = RdKafka::Conf::create(RdKafka::Conf::CONF_TOPIC);
 * Set configuration properties
conf->set("metadata.broker.list", brokers, errstr);
conf->set("event_cb", brokers, errstr);
conf->set("default_topic_conf", tconf, errstr);
 * Create producer using accumulated global configuration.
RdKafka::Producer *producer = RdKafka::Producer::create(conf, errstr);
    if (!producer) {
      std::cerr << "Failed to create producer: " << errstr << std::endl;
      exit(1);
RdKafka::Producer *producer = RdKafka::Producer::create(conf, errstr);
	if (!producer) 
		std::cerr << "Failed to create producer: " << errstr << std::endl;
		exit(1);

sudo g++ abc1.cpp -std=c++11 -I /usr/include -L/usr/local/lib/librdkafka++.so -lrdkafka++ -lpthread -lrt -lz -llz
./a.out

But it throws following error in both cases on Ubuntu terminal :-
./a.out: symbol lookup error: ./a.out: undefined symbol:_ZN7RdKafka8Producer6createEPNS_4ConfERSs

It seems Producer create is creating some problem.....

CAn you please suggest what to do next, in order to get rid of that????

https://github.com/edenhill/librdkafka/issues/new Producer create is creating some problems in ubuntu Jun 27, 2019

Thanks for your prompt reply, even after doing the same I get the same error on Ubuntu terminal : ./abc1: symbol lookup error: ./abc1: undefined symbol: _ZN7RdKafka8Producer6createEPNS_4ConfERSs

[Which seems to say "Producer Create" Problem.]

You are requested to please suggest, what else can be done.

In file included from /usr/include/c++/4.9/cstdint:35:0,
from /usr/local/include/json/config.h:9,
from /usr/local/include/json/forwards.h:10,
from /usr/local/include/json/value.h:10,
from /usr/local/include/json/writer.h:10,
from abc1.cpp:10:
/usr/include/c++/4.9/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the
In file included from /usr/local/include/json/config.h:127:0,
from /usr/local/include/json/forwards.h:10,
from /usr/local/include/json/value.h:10,
from /usr/local/include/json/writer.h:10,
from abc1.cpp:10:
/usr/local/include/json/allocator.h:18:9: error: expected nested-name-specifier before ‘value_type’
using value_type = T;
/usr/local/include/json/allocator.h:19:9: error: expected nested-name-specifier before ‘pointer’
using pointer = T*;
/usr/local/include/json/allocator.h:20:9: error: expected nested-name-specifier before ‘const_pointer’
using const_pointer = const T*;
/usr/local/include/json/allocator.h:21:9: error: expected nested-name-specifier before ‘reference’
using reference = T&;
/usr/local/include/json/allocator.h:22:9: error: expected nested-name-specifier before ‘const_reference’
using const_reference = const T&;
/usr/local/include/json/allocator.h:23:9: error: expected nested-name-specifier before ‘size_type’
using size_type = std::size_t;
/usr/local/include/json/allocator.h:24:9: error: expected nested-name-specifier before ‘difference_type’
using difference_type = std::ptrdiff_t;
/usr/local/include/json/allocator.h:29:3: error: ‘pointer’ does not name a type
pointer allocate(size_type n) {
/usr/local/include/json/allocator.h:41:28: error: ‘pointer’ does not name a type
void deallocate(volatile pointer p, size_type n) {
/usr/local/include/json/allocator.h:41:39: error: ‘size_type’ has not been declared
void deallocate(volatile pointer p, size_type n) {
/usr/local/include/json/allocator.h:50:46: error: ‘pointer’ has not been declared
template <typename... Args> void construct(pointer p, Args&&... args) {
/usr/local/include/json/allocator.h:50:61: error: expected ‘,’ or ‘...’ before ‘&&’ token
template <typename... Args> void construct(pointer p, Args&&... args) {
/usr/local/include/json/allocator.h:50:71: error: parameter packs not expanded with ‘...’:
template <typename... Args> void construct(pointer p, Args&&... args) {
/usr/local/include/json/allocator.h:50:71: note: ‘Args’
/usr/local/include/json/allocator.h:55:3: error: ‘size_type’ does not name a type
size_type max_size() const { return size_t(-1) / sizeof(T); }
/usr/local/include/json/allocator.h:57:3: error: ‘pointer’ does not name a type
pointer address(reference x) const { return std::addressof(x); }
/usr/local/include/json/allocator.h:59:3: error: ‘const_pointer’ does not name a type
const_pointer address(const_reference x) const { return std::addressof(x); }
/usr/local/include/json/allocator.h:64:16: error: ‘pointer’ has not been declared
void destroy(pointer p) {
/usr/local/include/json/allocator.h:72:47: error: expected nested-name-specifier before ‘other’
template struct rebind { using other = SecureAllocator; };
/usr/local/include/json/allocator.h: In member function ‘void Json::SecureAllocator::deallocate(int, int)’:
/usr/local/include/json/allocator.h:44:24: error: no matching function for call to ‘operator delete(volatile int&)’
::operator delete(p);
/usr/local/include/json/allocator.h:44:24: note: candidates are:
In file included from /usr/include/c++/4.9/ext/new_allocator.h:33:0,
from /usr/include/x86_64-linux-gnu/c++/4.9/bits/c++allocator.h:33,
from /usr/include/c++/4.9/bits/allocator.h:46,
from /usr/include/c++/4.9/string:41,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/istream:38,
from /usr/include/c++/4.9/sstream:38,
from abc1.cpp:3:
/usr/include/c++/4.9/new:132:6: note: void operator delete(void*)
void operator delete(void*) GLIBCXX_USE_NOEXCEPT
/usr/include/c++/4.9/new:132:6: note: no known conversion for argument 1 from ‘volatile int’ to ‘void*’
/usr/include/c++/4.9/new:140:6: note: void operator delete(void*, const std::nothrow_t&)
void operator delete(void*, const std::nothrow_t&) GLIBCXX_USE_NOEXCEPT
/usr/include/c++/4.9/new:140:6: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/4.9/new:152:13: note: void operator delete(void*, void*)
inline void operator delete (void*, void*) GLIBCXX_USE_NOEXCEPT { }
/usr/include/c++/4.9/new:152:13: note: candidate expects 2 arguments, 1 provided
In file included from /usr/local/include/json/config.h:127:0,
from /usr/local/include/json/forwards.h:10,
from /usr/local/include/json/value.h:10,
from /usr/local/include/json/writer.h:10,
from abc1.cpp:10:
/usr/local/include/json/allocator.h: In member function ‘void Json::SecureAllocator::construct(int, )’:
/usr/local/include/json/allocator.h:52:37: error: ‘forward’ is not a member of ‘std’
::new (static_cast<void*>(p)) T(std::forward(args)...);
/usr/local/include/json/allocator.h:52:54: error: expected primary-expression before ‘>’ token
::new (static_cast<void*>(p)) T(std::forward(args)...);
/usr/local/include/json/allocator.h:52:56: error: ‘args’ was not declared in this scope
::new (static_cast<void*>(p)) T(std::forward(args)...);
/usr/local/include/json/allocator.h: In member function ‘void Json::SecureAllocator::destroy(int)’:
/usr/local/include/json/allocator.h:66:6: error: base operand of ‘->’ is not a pointer
p->~T();
In file included from /usr/local/include/json/forwards.h:10:0,
from /usr/local/include/json/value.h:10,
from /usr/local/include/json/writer.h:10,
from abc1.cpp:10:
/usr/local/include/json/config.h: At global scope:
/usr/local/include/json/config.h:146:9: error: ‘uint64_t’ does not name a type
typedef uint64_t UInt64;
/usr/local/include/json/config.h:149:9: error: ‘UInt64’ does not name a type
typedef UInt64 LargestUInt;
/usr/local/include/json/config.h:154:1: error: expected unqualified-id before ‘using’
using Allocator = typename std::conditional<JSONCPP_USING_SECURE_MEMORY,
/usr/local/include/json/config.h:157:7: error: expected nested-name-specifier before ‘String’
using String = std::basic_string<char, std::char_traits, Allocator>;
/usr/local/include/json/config.h:158:7: error: expected nested-name-specifier before ‘IStringStream’
using IStringStream = std::basic_istringstream<String::value_type,
/usr/local/include/json/config.h:161:7: error: expected nested-name-specifier before ‘OStringStream’
using OStringStream = std::basic_ostringstream<String::value_type,
/usr/local/include/json/config.h:164:7: error: expected nested-name-specifier before ‘IStream’
using IStream = std::istream;
/usr/local/include/json/config.h:165:7: error: expected nested-name-specifier before ‘OStream’
using OStream = std::ostream;
/usr/local/include/json/config.h:169:7: error: expected nested-name-specifier before ‘JSONCPP_STRING’
using JSONCPP_STRING = Json::String;
/usr/local/include/json/config.h:170:7: error: expected nested-name-specifier before ‘JSONCPP_ISTRINGSTREAM’
using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
/usr/local/include/json/config.h:171:7: error: expected nested-name-specifier before ‘JSONCPP_OSTRINGSTREAM’
using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
/usr/local/include/json/config.h:172:7: error: expected nested-name-specifier before ‘JSONCPP_ISTREAM’
using JSONCPP_ISTREAM = Json::IStream;
/usr/local/include/json/config.h:173:7: error: expected nested-name-specifier before ‘JSONCPP_OSTREAM’
using JSONCPP_OSTREAM = Json::OStream;
In file included from /usr/local/include/json/writer.h:10:0,
from abc1.cpp:10:
/usr/local/include/json/value.h:60:20: error: expected ‘)’ before ‘msg’
Exception(String msg);
/usr/local/include/json/value.h:65:3: error: ‘String’ does not name a type
String msg
;
/usr/local/include/json/value.h:76:23: error: expected ‘)’ before ‘const’
RuntimeError(String const& msg);
/usr/local/include/json/value.h:87:21: error: expected ‘)’ before ‘const’
LogicError(String const& msg);
/usr/local/include/json/value.h:92:48: error: variable or field ‘throwRuntimeError’ declared void
JSONCPP_NORETURN void throwRuntimeError(String const& msg);
/usr/local/include/json/value.h:92:41: error: ‘String’ was not declared in this scope
JSONCPP_NORETURN void throwRuntimeError(String const& msg);
/usr/local/include/json/value.h:94:46: error: variable or field ‘throwLogicError’ declared void
JSONCPP_NORETURN void throwLogicError(String const& msg);
/usr/local/include/json/value.h:94:39: error: ‘String’ was not declared in this scope
JSONCPP_NORETURN void throwLogicError(String const& msg);
/usr/local/include/json/value.h:193:23: error: ‘String’ was not declared in this scope
typedef std::vector Members;
/usr/local/include/json/value.h:193:29: error: template argument 1 is invalid
typedef std::vector Members;
/usr/local/include/json/value.h:193:29: error: template argument 2 is invalid
/usr/local/include/json/value.h:199:17: error: ‘UInt64’ in namespace ‘Json’ does not name a type
typedef Json::UInt64 UInt64;
/usr/local/include/json/value.h:203:17: error: ‘LargestUInt’ in namespace ‘Json’ does not name a type
typedef Json::LargestUInt LargestUInt;
/usr/local/include/json/value.h:220:16: error: ‘LargestUInt’ does not name a type
static const LargestUInt maxLargestUInt;
/usr/local/include/json/value.h:235:16: error: ‘UInt64’ does not name a type
static const UInt64 maxUInt64;
/usr/local/include/json/value.h:256:22: error: expected ‘,’ or ‘...’ before ‘&&’ token
CZString(CZString&& other);
/usr/local/include/json/value.h:256:30: error: invalid constructor; you probably meant ‘Json::Value::CZString (const Json::Value::CZString&)’
CZString(CZString&& other);
/usr/local/include/json/value.h:259:33: error: expected ‘,’ or ‘...’ before ‘&&’ token
CZString& operator=(CZString&& other);
/usr/local/include/json/value.h:313:16: error: expected ‘)’ before ‘value’
Value(UInt64 value);
/usr/local/include/json/value.h:334:15: error: ‘String’ does not name a type
Value(const String& value); ///< Copy data() til size(). Embedded
/usr/local/include/json/value.h:341:14: error: expected ‘,’ or ‘...’ before ‘&&’ token
Value(Value&& other);
/usr/local/include/json/value.h:341:22: error: invalid constructor; you probably meant ‘Json::Value (const Json::Value&)’
Value(Value&& other);
/usr/local/include/json/value.h:347:25: error: expected ‘,’ or ‘...’ before ‘&&’ token
Value& operator=(Value&& other);
/usr/local/include/json/value.h:375:3: error: ‘String’ does not name a type
String asString() const; ///< Embedded zeroes are possible.
/usr/local/include/json/value.h:387:3: error: ‘UInt64’ does not name a type
UInt64 asUInt64() const;
/usr/local/include/json/value.h:390:3: error: ‘LargestUInt’ does not name a type
LargestUInt asLargestUInt() const;
/usr/local/include/json/value.h:468:22: error: expected ‘,’ or ‘...’ before ‘&&’ token
Value& append(Value&& value);
/usr/local/include/json/value.h:479:27: error: ‘String’ does not name a type
Value& operator[](const String& key);
/usr/local/include/json/value.h:483:33: error: ‘String’ does not name a type
const Value& operator[](const String& key) const;
/usr/local/include/json/value.h:516:19: error: ‘String’ does not name a type
Value get(const String& key, const Value& defaultValue) const;
/usr/local/include/json/value.h:538:27: error: ‘String’ does not name a type
void removeMember(const String& key);
/usr/local/include/json/value.h:548:21: error: ‘String’ has not been declared
bool removeMember(String const& key, Value* removed);
/usr/local/include/json/value.h:564:23: error: ‘String’ does not name a type
bool isMember(const String& key) const;
/usr/local/include/json/value.h:594:19: error: ‘String’ has not been declared
void setComment(String comment, CommentPlacement placement);
/usr/local/include/json/value.h:597:3: error: ‘String’ does not name a type
String getComment(CommentPlacement placement) const;
/usr/local/include/json/value.h:599:3: error: ‘String’ does not name a type
String toStyledString() const;
/usr/local/include/json/value.h:640:5: error: ‘LargestUInt’ does not name a type
LargestUInt uint
;
/usr/local/include/json/value.h:658:22: error: expected ‘,’ or ‘...’ before ‘&&’ token
Comments(Comments&& that);
/usr/local/include/json/value.h:658:29: error: invalid constructor; you probably meant ‘Json::Value::Comments (const Json::Value::Comments&)’
Comments(Comments&& that);
/usr/local/include/json/value.h:660:33: error: expected ‘,’ or ‘...’ before ‘&&’ token
Comments& operator=(Comments&& that);
/usr/local/include/json/value.h:662:5: error: ‘String’ does not name a type
String get(CommentPlacement slot) const;
/usr/local/include/json/value.h:663:37: error: ‘String’ has not been declared
void set(CommentPlacement slot, String s);
/usr/local/include/json/value.h:666:11: error: expected nested-name-specifier before ‘Array’
using Array = std::array<String, numberOfCommentPlacement>;
/usr/local/include/json/value.h:667:10: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type
std::unique_ptr ptr
;
/usr/local/include/json/value.h: In member function ‘void Json::Value::setComment(const char*, Json::CommentPlacement)’:
/usr/local/include/json/value.h:587:47: error: ‘String’ was not declared in this scope
setComment(String(comment, strlen(comment)), placement);
/usr/local/include/json/value.h: In member function ‘void Json::Value::setComment(const char*, size_t, Json::CommentPlacement)’:
/usr/local/include/json/value.h:591:35: error: ‘String’ was not declared in this scope
setComment(String(comment, len), placement);
/usr/local/include/json/value.h: At global scope:
/usr/local/include/json/value.h:687:22: error: ‘String’ does not name a type
PathArgument(const String& key);
/usr/local/include/json/value.h:691:3: error: ‘String’ does not name a type
String key_;
/usr/local/include/json/value.h:709:14: error: ‘String’ does not name a type
Path(const String& path,
/usr/local/include/json/value.h:726:23: error: ‘String’ does not name a type
void makePath(const String& path, const InArgs& in);
/usr/local/include/json/value.h:727:27: error: ‘String’ does not name a type
void addPathInArg(const String& path,
/usr/local/include/json/value.h:731:33: error: ‘String’ does not name a type
static void invalidPath(const String& path, int location);
/usr/local/include/json/value.h:765:3: error: ‘String’ does not name a type
String name() const;
In file included from abc1.cpp:10:0:
/usr/local/include/json/writer.h:44:3: error: ‘OStream’ does not name a type
OStream* sout_; // not owned; will not delete
/usr/local/include/json/writer.h:54:40: error: ‘OStream’ has not been declared
virtual int write(Value const& root, OStream* sout) = 0;
/usr/local/include/json/writer.h:71:1: error: ‘String’ does not name a type
String JSON_API writeString(StreamWriter::Factory const& factory,
/usr/local/include/json/writer.h:135:27: error: ‘String’ does not name a type
Value& operator[](const String& key);
/usr/local/include/json/writer.h:152:11: error: ‘String’ does not name a type
virtual String write(const Value& root) = 0;
/usr/local/include/json/writer.h:186:3: error: ‘String’ does not name a type
String write(const Value& root) override;
/usr/local/include/json/writer.h:191:3: error: ‘String’ does not name a type
String document_;
/usr/local/include/json/writer.h:239:3: error: ‘String’ does not name a type
String write(const Value& root) override;
/usr/local/include/json/writer.h:245:24: error: ‘String’ does not name a type
void pushValue(const String& value);
/usr/local/include/json/writer.h:247:30: error: ‘String’ does not name a type
void writeWithIndent(const String& value);
/usr/local/include/json/writer.h:253:10: error: ‘String’ does not name a type
static String normalizeEOL(const String& text);
/usr/local/include/json/writer.h:255:23: error: ‘String’ was not declared in this scope
typedef std::vector ChildValues;
/usr/local/include/json/writer.h:255:29: error: template argument 1 is invalid
typedef std::vector ChildValues;
/usr/local/include/json/writer.h:255:29: error: template argument 2 is invalid
/usr/local/include/json/writer.h:258:3: error: ‘String’ does not name a type
String document_;
/usr/local/include/json/writer.h:259:3: error: ‘String’ does not name a type
String indentString_;
/usr/local/include/json/writer.h:303:29: error: expected ‘)’ before ‘indentation’
StyledStreamWriter(String indentation = "\t");
/usr/local/include/json/writer.h:313:14: error: ‘OStream’ has not been declared
void write(OStream& out, const Value& root);
/usr/local/include/json/writer.h:319:24: error: ‘String’ does not name a type
void pushValue(const String& value);
/usr/local/include/json/writer.h:321:30: error: ‘String’ does not name a type
void writeWithIndent(const String& value);
/usr/local/include/json/writer.h:327:10: error: ‘String’ does not name a type
static String normalizeEOL(const String& text);
/usr/local/include/json/writer.h:329:23: error: ‘String’ was not declared in this scope
typedef std::vector ChildValues;
/usr/local/include/json/writer.h:329:29: error: template argument 1 is invalid
typedef std::vector ChildValues;
/usr/local/include/json/writer.h:329:29: error: template argument 2 is invalid
/usr/local/include/json/writer.h:332:3: error: ‘OStream’ does not name a type
OStream* document_;
/usr/local/include/json/writer.h:333:3: error: ‘String’ does not name a type
String indentString_;
/usr/local/include/json/writer.h:335:3: error: ‘String’ does not name a type
String indentation_;
/usr/local/include/json/writer.h:344:1: error: ‘String’ does not name a type
String JSON_API valueToString(Int value);
/usr/local/include/json/writer.h:345:1: error: ‘String’ does not name a type
String JSON_API valueToString(UInt value);
/usr/local/include/json/writer.h:347:1: error: ‘String’ does not name a type
String JSON_API valueToString(LargestInt value);
/usr/local/include/json/writer.h:348:1: error: ‘String’ does not name a type
String JSON_API valueToString(LargestUInt value);
/usr/local/include/json/writer.h:349:1: error: ‘String’ does not name a type
String JSON_API
/usr/local/include/json/writer.h:353:1: error: ‘String’ does not name a type
String JSON_API valueToString(bool value);
/usr/local/include/json/writer.h:354:1: error: ‘String’ does not name a type
String JSON_API valueToQuotedString(const char* value);
/usr/local/include/json/writer.h:358:10: error: ‘OStream’ does not name a type
JSON_API OStream& operator<<(OStream&, const Value& root);
In file included from /usr/local/include/json/json.h:11:0,
from abc1.cpp:12:
/usr/local/include/json/reader.h:49:5: error: ‘String’ does not name a type
String message;
/usr/local/include/json/reader.h:106:14: error: ‘IStream’ has not been declared
bool parse(IStream& is, Value& root, bool collectComments = true);
/usr/local/include/json/reader.h:118:3: error: ‘String’ does not name a type
String getFormatedErrorMessages() const;
/usr/local/include/json/reader.h:128:3: error: ‘String’ does not name a type
String getFormattedErrorMessages() const;
/usr/local/include/json/reader.h:145:44: error: ‘String’ does not name a type
bool pushError(const Value& value, const String& message);
/usr/local/include/json/reader.h:154:44: error: ‘String’ does not name a type
bool pushError(const Value& value, const String& message, const Value& extra);
/usr/local/include/json/reader.h:190:5: error: ‘String’ does not name a type
String message_;
/usr/local/include/json/reader.h:210:35: error: ‘String’ has not been declared
bool decodeString(Token& token, String& decoded);
/usr/local/include/json/reader.h:221:23: error: ‘String’ does not name a type
bool addError(const String& message, Token& token, Location extra = nullptr);
/usr/local/include/json/reader.h:223:33: error: ‘String’ does not name a type
bool addErrorAndRecover(const String& message,
/usr/local/include/json/reader.h:231:3: error: ‘String’ does not name a type
String getLocationLineAndColumn(Location location) const;
/usr/local/include/json/reader.h:236:10: error: ‘String’ does not name a type
static String normalizeEOL(Location begin, Location end);
/usr/local/include/json/reader.h:241:3: error: ‘String’ does not name a type
String document_;
/usr/local/include/json/reader.h:247:3: error: ‘String’ does not name a type
String commentsBefore_;
/usr/local/include/json/reader.h:221:71: error: ‘nullptr’ was not declared in this scope
bool addError(const String& message, Token& token, Location extra = nullptr);
/usr/local/include/json/reader.h:278:22: error: ‘String’ has not been declared
String* errs) = 0;
/usr/local/include/json/reader.h:358:27: error: ‘String’ does not name a type
Value& operator[](const String& key);
/usr/local/include/json/reader.h:347:3: error: looser throw specifier for ‘virtual Json::CharReaderBuilder::~CharReaderBuilder()’
~CharReaderBuilder() override;
/usr/local/include/json/reader.h:282:13: error: overriding ‘virtual Json::CharReader::Factory::~Factory() throw ()’
virtual ~Factory() = default;
/usr/local/include/json/reader.h:379:31: error: ‘IStream’ has not been declared
IStream&,
/usr/local/include/json/reader.h:407:10: error: ‘IStream’ does not name a type
JSON_API IStream& operator>>(IStream&, Value&);

Now I even tried using other system. While trying on other system(with ubuntu 16) with the following command:-
g++ -o abc1 abc1.cpp -std=c++11 -lrdkafka++ -lrt -lpthread

in function main:
abc1.cpp (.text+0x536): undefined reference to 'RDkadka::Producer::create(RdKafka::Conf*, std:__cxx11::basic_string<char, std:: char_traits,std::allocatorcollect2:error : ld returned 1 exit status

On my previous system after doing

$ g++ -o abc1 abc1.cpp -std=c++11 -lrdkafka++ -lrt -lpthread
$ ldd ./abc1
$ ./abc1

I used to get the following error:-
./abc1: symbol lookup error: ./abc1: undefined symbol: _ZN7RdKafka8Producer6createEPNS_4ConfERSs

abc1.cpp (.text+0x536): undefined reference to 'RDkadka::Producer::create(RdKafka::Conf*, std:__cxx11::basic_string<char, std:: char_traits,std::allocatorcollect2:error : ld returned 1 exit status

there's a typo there: RDkadka

RdKafka::Headers *headers = RdKafka::Headers::create(); headers->add("my header", "header value"); headers->add("other header", "yes"); //Json::StreamWriterBuilder builder; //builder.settings_["indentation"] = ""; //std::string out = Json::writeString(builder, detectionEvent); //cout << " out value " << out << endl; RdKafka::ErrorCode resp = producer->produce("SJ", RdKafka::Topic::PARTITION_UA, RdKafka::Producer::RK_MSG_COPY /* Copy payload */, /* Value */ const_cast<char *>(out.c_str()), out.size(), /* Key */ NULL, 0, /* Timestamp (defaults to now) */ /* Message headers, if any */ headers, /* Per-message opaque value passed to * delivery report */ NULL); cout<<resp<<endl; int main() * Create configuration objects cout<<"Test1:"; std::string brokers = "192.168.1.4"; //Kafka Server or consumer ip address here"192.168.100.1"; std::string errstr; RdKafka::Conf *conf = RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL); RdKafka::Conf *tconf = RdKafka::Conf::create(RdKafka::Conf::CONF_TOPIC); * Set configuration properties conf->set("metadata.broker.list", brokers, errstr); conf->set("event_cb", brokers, errstr); conf->set("default_topic_conf", tconf, errstr); * Create producer using accumulated global configuration. RdKafka::Producer *producer = RdKafka::Producer::create(conf, errstr); if (!producer) { std::cerr << "Failed to create producer: " << errstr << std::endl; exit(1); RdKafka::Producer *producer = RdKafka::Producer::create(conf, errstr); if (!producer) std::cerr << "Failed to create producer: " << errstr << std::endl; exit(1); //Json::Value detectEvent; //detectEvent["adapterSource"]["adapterId"] = "TrackDetectionLidar001" ; //detectEvent["adapterSource"]["adapterName"] = "Track Detection Lidar 001"; //detectEvent["adapterSource"]["adapterType"] = "Track Detection Lidar"; //detectEvent["adapterSource"]["adapterVersion"] = "1.0"; //detectEvent["adapterSource"]["adapterOS"] = "Windows 10(like aa noob)"; //detectEvent["eventData"]["eventType"] = "objectDetection"; //detectEvent["eventData"]["eventVersion"] = "1.0"; //Json::Value kafkaEventToSend = detectEvent; //kafkaEventToSend["eventData"]["detectionBoxes"] = 1; //kafkaEventToSend["startTime"] = 2; //kafkaEventToSend["endTime"] = 3; cout<<"hey"<<endl; //sendKafkaEvent(producer, "hello"); return 0;

I tried this(-lrdkafka++), but still I am getting the following error:-
I am getting following error
undefined reference to `RdKafka::Producer::create(RdKafka::Conf*, std::__cxx11::basic_string<char, std::char_traits, std::allocator >&)'

Can you try removing the debian packages of librdkafka (apt purge librdkafka1 librdkafka++1 librdkafka-dev) and installing librdkafka from source instead?

  • Download and extact https://github.com/edenhill/librdkafka/archive/v1.1.0.tar.gz
  • ./configure --prefix=/usr
  • sudo make install
  • Then try building your program again