undefined reference to librados::Rados::read

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm writing sample code of RADOS client to learn RADOS API, and I'm
stacking on librados::Rados::read().
It could compile, but cannot link due to this error:
get_obj.cc:(.text+0x315): undefined reference to
`librados::Rados::read(void*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, long,
ceph::buffer::list&, unsigned int)'

Here's the code:
====
#include <errno.h>
#include <stdlib.h>

#include <rados/librados.hpp>
using namespace librados;

#include <string>
using namespace std;

#define ROOT_BUCKET ".rgw" //keep this synced to rgw_user.cc::root_bucket!
static string root_bucket(ROOT_BUCKET);
static pool_t root_pool;

/**
* Open the pool used as root for this gateway
* Returns: 0 on success, -ERR# otherwise.
*/
int open_root_pool(Rados &rados, pool_t *pool)
{
  int r = rados.open_pool(root_bucket.c_str(), pool);
  if (r < 0) {
    r = rados.create_pool(root_bucket.c_str());
    if (r < 0)
      return r;

    r = rados.open_pool(root_bucket.c_str(), pool);
  }

  return r;
}

int main(int argc, const char **argv)
{
  int r;
  Rados rados;
  const char *bucket = argv[1];
  string oid(argv[2]);
  string file_name(argv[3]);
  pool_t pool;
  bufferlist bl;

  r = rados.initialize(0, NULL);
  if (r < 0)
    goto err;

  r = open_root_pool(rados, &root_pool);
  if (r < 0)
    goto err;

  r = rados.open_pool(bucket, &pool);
  if (r < 0)
    goto err;


  r = rados.read(pool, oid, 0, bl, 0);
  if (r < 0)
    goto err;

  r = bl.write_file(file_name.c_str());

 err:
  rados.close_pool(pool);
  rados.close_pool(&root_pool);
  rados.shutdown();

  return r;
}
====

Then, compile & link following command:
# g++ -lcrypto -lrados -lcrush get_obj.cc
/tmp/cctA2uA8.o: In function `main':
get_obj.cc:(.text+0x315): undefined reference to
`librados::Rados::read(void*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, long,
ceph::buffer::list&, unsigned int)'
collect2: ld returned 1 exit status

Do you have any idea with this?


syuu
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux