Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7523433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:48:03+00:00 2026-05-30T02:48:03+00:00

I was trying to compile a simple example for connecting to a cassandra instance

  • 0

I was trying to compile a simple example for connecting to a cassandra instance using the thrift interface. As a note, I am doing all of this without access to super user privileges on a linux machine.

I installed thrift and the c++ generator, put the include headers on my CPLUS_INCLUDE_PATH variable, and the lib directory on my LIBRARY_PATH, and LD_LIBRARY_PATH. Cassandra is also installed and I ran thrift --gen cpp cassandra.thrift to generate the cassandra header files.

Using those I compiled my example like so
g++ -Wall run_measure.cpp cassandra_constants.cpp Cassandra.cpp cassandra_types.cpp -lthrift -o cassandra_example

The program looks mostly like this

#include "Cassandra.h"

#include <protocol/TBinaryProtocol.h>
#include <transport/TSocket.h>
#include <transport/TTransportUtils.h>

using namespace std;
using namespace apache::thrift;
using namespace apache::thrift::protocol;
using namespace apache::thrift::transport;
using namespace org::apache::cassandra;
using namespace boost;

int main(int argc, const char* argv[]) {
    shared_ptr socket(new TSocket(host, port));
    shared_ptr transport(new TFramedTransport(socket));
    shared_ptr protocol(new TBinaryProtocol(transport));
    CassandraClient client(protocol);

    const string& key="your_key";

    ColumnPath cpath;
    ColumnParent cp;

    ColumnOrSuperColumn csc;
    Column c;

    c.name.assign("column_name");
    c.value.assign("Data for our key to go into column_name");
    c.timestamp = getTS();
    c.ttl = 300;

    cp.column_family.assign("nm_cfamily");
    cp.super_column.assign("");

    cpath.column_family.assign("nm_cfamily");
    /* This is required - thrift 'feature' */
    cpath.__isset.column = true;
    cpath.column="column_name";
    try {
            transport->open();
            cout << "Set keyspace to 'dpdns'.." << endl;
            client.set_keyspace("nm_example");

            cout << "Insert key '" << key << "' in column '" << c.name << "' in column family '" << cp.column_family << "' with timestamp " << c.timestamp << "..." << endl;
            client.insert(key, cp, c, org::apache::cassandra::ConsistencyLevel::ONE);

            cout << "Retrieve key '" << key << "' from column '" << cpath.column << "' in column family '" << cpath.column_family << "' again..." << endl;
            client.get(csc, key, cpath, org::apache::cassandra::ConsistencyLevel::ONE);
            cout << "Value read is '" << csc.column.value << "'..." << endl;

            c.timestamp++;
            c.value.assign("Updated data going into column_name");
            cout << "Update key '" << key << "' in column with timestamp " << c.timestamp << "..." << endl;
            client.insert(key, cp, c, org::apache::cassandra::ConsistencyLevel::ONE);

            cout << "Retrieve updated key '" << key << "' from column '" << cpath.column << "' in column family '" << cpath.column_family << "' again..." << endl;
            client.get(csc, key, cpath, org::apache::cassandra::ConsistencyLevel::ONE);
            cout << "Updated value is: '" << csc.column.value << "'" << endl;

            cout << "Remove the key '" << key << "' we just retrieved. Value '" << csc.column.value << "' timestamp " << csc.column.timestamp << " ..." << endl;
    client.remove(key, cpath, csc.column.timestamp, org::apache::cassandra::ConsistencyLevel::ONE);

    transport->close();
}
catch (NotFoundException &nf){
cerr << "NotFoundException ERROR: "<< nf.what() << endl;
}
catch (InvalidRequestException &re) {
cerr << "InvalidRequest ERROR: " << re.why << endl;
}
catch (TException &tx) {
cerr << "TException ERROR: " << tx.what() << endl;
}

return 0;
}

The errors that I get are

In file included from run_measure.cpp:13:
Cassandra.h:4289: error: ‘org::apache::thrift’ has not been declared
Cassandra.h:4289: error: expected ‘,’ or ‘...’ before ‘*’ token
Cassandra.h:4291: error: cannot declare pointer to ‘void’ member
Cassandra.h:4291: error: template argument 2 is invalid
Cassandra.h:4291: error: template argument 4 is invalid
Cassandra.h:4292: error: ‘org::apache::thrift’ has not been declared
Cassandra.h:4292: error: expected ‘,’ or ‘...’ before ‘*’ token
Cassandra.h:4293: error: ‘org::apache::thrift’ has not been declared
Cassandra.h:4293: error: expected ‘,’ or ‘...’ before ‘*’ token
Cassandra.h:4294: error: ‘org::apache::thrift’ has not been declared
Cassandra.h:4294: error: expected ‘,’ or ‘...’ before ‘*’ token
Cassandra.h:4295: error: ‘org::apache::thrift’ has not been declared
Cassandra.h:4295: error: expected ‘,’ or ‘...’ before ‘*’ token

Its complaining mostly about things in the generated files so I am not sure if I can change them or if I did something else wrong. As reference my thrift install is to $HOME/thrift so the path of the include is a little wierd, it looks like $HOME/thrift/include/thrift but I don’t think that would cause this error. If anyone has any experience using cassandra in c++ I would really appreciate the help.

Here are the lines referenced in the error

  while (true)
  {
    xfer += iprot->readFieldBegin(fname, ftype, fid);
    if (ftype == ::apache::thrift::protocol::T_STOP) {
      break;
    }
    switch (fid)
    {
      default:
        xfer += iprot->skip(ftype);
        break;
    }
    xfer += iprot->readFieldEnd();
  }

  xfer += iprot->readStructEnd();

  return xfer;
}

Full Cassandra.cpp
Full Error

Thanks again!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:48:05+00:00Added an answer on May 30, 2026 at 2:48 am

    I have the same problem and fixed it:
    for gcc you should add changes in Cassandra.h, Cassandra.cpp.

    replace apache::thrift -> ::apache::thrift

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to compile the simple C example from this tutorial on Ubuntu
I am just trying to compile this simple example : http://msdn.microsoft.com/en-us/library/ms533895(VS.85).aspx what needs to
I'm trying to compile a simple example of generic classes / type patterns (see
I'm trying to compile the following simple DL library example code from Program-Library-HOWTO with
i am trying to compile this very simple piece of code class myList {
Trying to build the following simple example #include <boost/python.hpp> using namespace boost::python; tuple head_and_tail(object
I'm trying to get a simple example working using gSoap, for VS2008. I've done
I'm trying to compile a simple calculator example that I found in the internet
I am trying to compile a simple cython extension from the example page here
I'm trying to compile a simple example from thrust graph. At the moment I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.