You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Raghava Mutharaju <m....@gmail.com> on 2010/07/25 09:58:53 UTC

linker error after change in thrift file

Hi all,

This might not be entirely a thrift related question but it happened when I
made a change in the thrift file. Before making the change, everything was
working fine. I made a change to the thrift file and regenerated cpp & java
classes. After this change, I started getting linker errors in cpp. Here is
the error

Undefined symbols:

"com::XXXX::thrift::employee::SavingsInfo::operator<(com::XXXX::thrift::employee::SavingsInfo
const&) const", referenced from:

std::less<com::XXXX::thrift::employee::SavingsInfo>::operator()(com::XXXX::thrift::employee::SavingsInfo
const&, com::XXXX::thrift::employee::SavingsInfo const&) constin
employee_types.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [ThriftCPPSamples] Error 1

I added SavingsInfo type to thrift file, this is the change. I give all the
options mentioned in the doc to g++. I gave -I/usr/local/include/thrift,
-I/path-to-boost, -L/path-to-boost-lib, -lthrift. But after the change I
started getting the above linker error. I couldn't understand the reason for
this. The error points to something that was generated by thrift. What could
be the reason for the error?

Thank you.

Regards,
Raghava.

Re: linker error after change in thrift file

Posted by Raghava Mutharaju <m....@gmail.com>.
Hi,

Since this error is related to "operator <", I have removed other code from
the files. Only the relevant code is present in the below 2 links.

employee_types.h -- http://pastebin.com/gibYVkRw
employee_types.cpp -- http://pastebin.com/TcdTkhSj

Also, I tried the following things:

   1. Instead of using set<SavingsInfo>, I tried SavingsInfo and it worked.
   Savings is a field in EmployeeInfo
   2. I commented out "operator <" because I thought it is not being used
   anywhere, but I got the following build error.

Building file: ../src/employee_types.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/local/include/thrift
-I/Users/raghava/Software/Boost_C++_Library/boost_1_43_0 -O0 -g3 -Wall -c
-fmessage-length=0 -MMD -MP -MF"src/employee_types.d"
-MT"src/employee_types.d" -o"src/employee_types.o"
"../src/employee_types.cpp"
/usr/include/c++/4.2.1/bits/stl_function.h: In member function 'bool
std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp =
com::xxxx::thrift::employee::SavingsInfo]':
/usr/include/c++/4.2.1/bits/stl_tree.h:982:   instantiated from
'std::pair<typename std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare,
_Alloc>::iterator, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare,
_Alloc>::_M_insert_unique(const _Val&) [with _Key =
com::xxxx::thrift::employee::SavingsInfo, _Val =
com::xxxx::thrift::employee::SavingsInfo, _KeyOfValue =
std::_Identity<com::xxxx::thrift::employee::SavingsInfo>, _Compare =
std::less<com::xxxx::thrift::employee::SavingsInfo>, _Alloc =
std::allocator<com::xxxx::thrift::employee::SavingsInfo>]'
/usr/include/c++/4.2.1/bits/stl_set.h:307:   instantiated from
'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>,
_Compare, typename _Alloc::rebind<_Key>::other>::const_iterator, bool>
std::set<_Key, _Compare, _Alloc>::insert(const _Key&) [with _Key =
com::xxxx::thrift::employee::SavingsInfo, _Compare =
std::less<com::xxxx::thrift::employee::SavingsInfo>, _Alloc =
std::allocator<com::xxxx::thrift::employee::SavingsInfo>]'
../src/employee_types.cpp:163:   instantiated from here
/usr/include/c++/4.2.1/bits/stl_function.h:227: error: no match for
'operator<' in '__x < __y'
make: *** [src/employee_types.o] Error 1


Why is "operator <" overloaded? What could be the reason for the linker
error (mentioned earlier)?

Thank you.

Regards,
Raghava.

On Sun, Jul 25, 2010 at 3:56 PM, Raghava Mutharaju <
m.vijayaraghava@gmail.com> wrote:

> Hi,
>
> The source files in which SavingsInfo is used are given below
>
> employee_types.h -- http://pastebin.com/JGzE8V6J
> employee_types.cpp -- http://pastebin.com/7dLtstCK
>
> Regards,
> Raghava.
>
>
> On Sun, Jul 25, 2010 at 3:58 AM, Raghava Mutharaju <
> m.vijayaraghava@gmail.com> wrote:
>
>> Hi all,
>>
>> This might not be entirely a thrift related question but it happened when
>> I made a change in the thrift file. Before making the change, everything was
>> working fine. I made a change to the thrift file and regenerated cpp & java
>> classes. After this change, I started getting linker errors in cpp. Here is
>> the error
>>
>> Undefined symbols:
>>
>> "com::XXXX::thrift::employee::SavingsInfo::operator<(com::XXXX::thrift::employee::SavingsInfo
>> const&) const", referenced from:
>>
>> std::less<com::XXXX::thrift::employee::SavingsInfo>::operator()(com::XXXX::thrift::employee::SavingsInfo
>> const&, com::XXXX::thrift::employee::SavingsInfo const&) constin
>> employee_types.o
>> ld: symbol(s) not found
>> collect2: ld returned 1 exit status
>> make: *** [ThriftCPPSamples] Error 1
>>
>> I added SavingsInfo type to thrift file, this is the change. I give all
>> the options mentioned in the doc to g++. I gave -I/usr/local/include/thrift,
>>
>> -I/path-to-boost, -L/path-to-boost-lib, -lthrift. But after the change I
>> started getting the above linker error. I couldn't understand the reason for
>> this. The error points to something that was generated by thrift. What could
>> be the reason for the error?
>>
>> Thank you.
>>
>> Regards,
>> Raghava.
>>
>
>

Re: linker error after change in thrift file

Posted by Raghava Mutharaju <m....@gmail.com>.
Hi,

The source files in which SavingsInfo is used are given below

employee_types.h -- http://pastebin.com/JGzE8V6J
employee_types.cpp -- http://pastebin.com/7dLtstCK

Regards,
Raghava.

On Sun, Jul 25, 2010 at 3:58 AM, Raghava Mutharaju <
m.vijayaraghava@gmail.com> wrote:

> Hi all,
>
> This might not be entirely a thrift related question but it happened when I
> made a change in the thrift file. Before making the change, everything was
> working fine. I made a change to the thrift file and regenerated cpp & java
> classes. After this change, I started getting linker errors in cpp. Here is
> the error
>
> Undefined symbols:
>
> "com::XXXX::thrift::employee::SavingsInfo::operator<(com::XXXX::thrift::employee::SavingsInfo
> const&) const", referenced from:
>
> std::less<com::XXXX::thrift::employee::SavingsInfo>::operator()(com::XXXX::thrift::employee::SavingsInfo
> const&, com::XXXX::thrift::employee::SavingsInfo const&) constin
> employee_types.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> make: *** [ThriftCPPSamples] Error 1
>
> I added SavingsInfo type to thrift file, this is the change. I give all the
> options mentioned in the doc to g++. I gave -I/usr/local/include/thrift,
> -I/path-to-boost, -L/path-to-boost-lib, -lthrift. But after the change I
> started getting the above linker error. I couldn't understand the reason for
> this. The error points to something that was generated by thrift. What could
> be the reason for the error?
>
> Thank you.
>
> Regards,
> Raghava.
>