Dear Sergey Shelukhin,
   Thanks very much for your reply, and I have found out the reason.
   I should put the -lthrift flag at the end of the command line, thanks to the 
stackoverflow problem?? 
http://stackoverflow.com/questions/7337292/does-linking-switch-order-matters??

   And according to my experience, a modification of Makefile is needed to make 
DemoClient.cpp compile and run. Do you or some other ones have the same problem?

  Thanks


yours,
Ling Kun
=============   The modification ==================================

diff --git a/hbase-examples/src/main/cpp/Makefile 
b/hbase-examples/src/main/cpp/Makefile
index aab5951..30ffef4 100644
--- a/hbase-examples/src/main/cpp/Makefile
+++ b/hbase-examples/src/main/cpp/Makefile
@@ -28,7 +28,7 @@ GEN_SRC = ./gen-cpp/Hbase.cpp \
 default: DemoClient
 
 DemoClient: DemoClient.cpp
-       g++ -o DemoClient -I${THRIFT_DIR}  -I./gen-cpp -L${LIB_DIR} 
-Wl,-rpath,${LIB_DIR} -lthrift DemoClient.cpp ${GEN_SRC}
+       g++ -o DemoClient -I${THRIFT_DIR}  -I./gen-cpp -L${LIB_DIR} 
-Wl,-rpath,${LIB_DIR} DemoClient.cpp ${GEN_SRC} -lthrift
 
 clean:
        rm -rf DemoClient

===================================================================    



------------------ Original ------------------
From:  "Sergey Shelukhin"<[email protected]>;
Date:  Tue, Feb 26, 2013 03:30 AM
To:  "user"<[email protected]>; 

Subject:  Re: Any code example for access HBase using C++ except theout-of-date 
Democlient.cpp ?



At some point few months ago, I think I was able to make cpp sample from
trunk compile and link (against trunk).
I think one of the problems on the way was that some HBase thrift classes
got renamed between versions of thrift used before and after (in your case,
94 and current trunk).
Can you check the thrift generated code, thrift headers you use to compile,
and thrift you are actually linking against, for, respectively, usage,
declaration and definition of this ctor?
I am not sure how, you might be compiling against thrift headers of one
version but linking against a different one...

On Sun, Feb 24, 2013 at 5:19 PM, Kun Ling <[email protected]> wrote:

> Dear All,
>     I am writing for some C++ code example for using HBase.
>
>     After Google and look into the HBase Document, I found that C++ code
> can  connect to HBase using Thrift Interface.
>
>     However, when compile the DemoClient.cpp within the latest HBase
> release package, it seems that this file is out of date(plenty of APIs need
> a new std::map<Text, Text> & attributes parameter ).
>
>     And I have also tried to replace  the DemoClient.cpp with the latest
> trunk version. However, after some modification there are still link
> problems when compile the code( undefined reference to
> `apache::thrift::transport::TSocket::TSocket(std::string, int)', I have
> passed the -lthrift parameter to gcc).
>
>   Is there anyone who can kindly show some can-work C++ code for HBase
> connection?  Or does anyone have any experience on this error?
>
>
>   Thanks.
> Kun Ling

Reply via email to