On 07/28/2011 03:19 PM, Matthieu Imbert wrote:
Hi Gautam and all,

I have the same issue: when compiling a thrift client with g++ 4.6.1
(debian testing) and the latest thrift from the subversion, i get
messages about undefined references to VERSION_1 and VERSION_MASK

For example:

/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:35: undefined
reference to
`apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::VERSION_1'


I know this particular client was compiling correctly 1 year ago (with a
different gcc and thrift version).

But isn't it normal that the linker complains? since VERSION_1 and
VERSION_MASK are *declared* in TBinaryProtocol.h, but never *defined*.
I'm far from being a c++ expert, but i think that even if you're allowed
to declare a static const integral value in a class header, you're still
supposed to define it somewhere so that it exists in an object file?

Actually, declaring a static const integral in header is sufficient if the compiler does not need its address. See for example Stroustrup faq http://www2.research.att.com/~bs/bs_faq2.html#in-class

So the code should compile fine.

I also tried to compile with various g++ version:

g++ 4.4.6: OK

g++ 4.5.3: OK

g++ 4.6.1: complains about undefined reference to `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::VERSION_1' and undefined reference to `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::VERSION_MASK'

--
Matthieu

Reply via email to