thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rush Manbert <r...@manbert.com>
Subject Re: Any idea why build failed on cpp?
Date Tue, 17 Aug 2010 17:10:07 GMT
Hi Basu,

In truth, this seems like more of a documentation issue to me. And the OP could have found
the answer with a goggle search, since this question came up and was answered at the end of
July. (It had never come up before that. My personal Thrift mailing list starts on 4/25/08
and no one ever asked about this until now. Is that because Thrift usage is moving beyond
the "expert user" group?)

- Rush

On Aug 16, 2010, at 6:15 PM, Basu Chaudhuri wrote:

> Rush,
> 
> This is a common mistake, especially for people new to C++ and/or STL. Would be possible
to output a reminder or warning by default from the thrift-compiler to tell the user that
he/she needs to create the corresponding definition for the operator.
> 
> Basu
> 
> 
> -----Original Message-----
> From: Rush Manbert [mailto:rush@manbert.com] 
> Sent: Monday, August 16, 2010 5:40 PM
> To: thrift-user@incubator.apache.org
> Subject: Re: Any idea why build failed on cpp?
> 
> Because the code generator declares but does not define operator<, which is required
to insert into a set. You will need to implement those for Pet, Specialty, and Visit. I think
you just need to write a file specifically for this that includes the petclinic_types.h file.
> 
> - Rush
> 
> On Aug 16, 2010, at 5:22 PM, EY Tsai wrote:
> 
>> 
>> g++ -o CppClinicClient -I./gen-cpp -I/usr/local/include/thrift -I/usr/include/boost/
 -I./ -L/usr/local/lib -lthrift main/CppClinicClient.cpp gen-cpp/petclinic_constants.cpp gen-cpp/petclinic_types.cpp
 gen-cpp/PetClinic.cpp
>> /tmp/ccSEmUDT.o: In function `std::less<tc_petclinic::Specialty>::operator()(tc_petclinic::Specialty
const&, tc_petclinic::Specialty const&) const':
>> petclinic_types.cpp:(.text._ZNKSt4lessIN12tc_petclinic9SpecialtyEEclERKS1_S4_[std::less<tc_petclinic::Specialty>::operator()(tc_petclinic::Specialty
const&, tc_petclinic::Specialty const&) const]+0x14): undefined reference to `tc_petclinic::Specialty::operator<(tc_petclinic::Specialty
const&) const'
>> /tmp/ccSEmUDT.o: In function `std::less<tc_petclinic::Visit>::operator()(tc_petclinic::Visit
const&, tc_petclinic::Visit const&) const':
>> petclinic_types.cpp:(.text._ZNKSt4lessIN12tc_petclinic5VisitEEclERKS1_S4_[std::less<tc_petclinic::Visit>::operator()(tc_petclinic::Visit
const&, tc_petclinic::Visit const&) const]+0x14): undefined reference to `tc_petclinic::Visit::operator<(tc_petclinic::Visit
const&) const'
>> /tmp/ccSEmUDT.o: In function `std::less<tc_petclinic::Pet>::operator()(tc_petclinic::Pet
const&, tc_petclinic::Pet const&) const':
>> petclinic_types.cpp:(.text._ZNKSt4lessIN12tc_petclinic3PetEEclERKS1_S4_[std::less<tc_petclinic::Pet>::operator()(tc_petclinic::Pet
const&, tc_petclinic::Pet const&) const]+0x14): undefined reference to `tc_petclinic::Pet::operator<(tc_petclinic::Pet
const&) const'
>> collect2: ld returned 1 exit status
>> make: *** [client] Error 1
>> 
>> petclinic.thrif:
>> 
>> struct PetType {
>> 1: i32 id,
>> 2: string name
>> }
>> 
>> struct Specialty {
>> 1: i32 id,
>> 2: string name
>> }
>> 
>> struct Vet {
>> 1: i32 id,
>> 2: string firstName,
>> 3: string lastName,
>> 4: set<Specialty>  specialties
>> }
>> 
>> struct Visit {
>> 1: i32 id,
>> 2: i64 date,
>> 3: string description,
>> 4: i32 petFK
>> }
>> 
>> struct Pet {
>> 1: i32 id,
>> 2: string name
>> 3: string birthDate,
>> 4: PetType type,
>> 5: set<Visit>  visits,
>> 6: i32 ownerFK,
>> 7: i32 typeFK
>> }
>> 
>> struct Owner {
>> 1: i32 id,
>> 2: string firstName,
>> 3: string lastName
>> 4: i32 account,
>> 5: string address,
>> 6: string city,
>> 7: string telephone,
>> 8: set<Pet>  pets
>> }
>> 
>> service PetClinic {
>> void putPetType(1: PetType petType),
>> PetType getPetType(1: i32 id),
>> void putPet(1: Pet pet),
>> Pet getPet(1: i32 id),
>> void putVisit(1: Visit visit),
>> Visit getVisit(1: i32 id),
>> void putOwnerPets(1: i32 ownerId, 2: set<Pet>  pets),
>> set<Pet>  getOwnerPets(1: i32 ownerId),
>> void putPetVisits(1: i32 petId, 2: set<Visit>  visits),
>> set<Visit>  getPetVisits(1: i32 petId),
>> void putOwner(1: Owner owner),
>> Owner getOwner(1: i32 id)
>> }
>> 
>> Thanks
>> 
>> 


Mime
View raw message