Odd...  it's as if addressbook.pb.cc's static initializers were run twice
(so it was registered in the global descriptor pool twice, and on the second
instance you saw the error).
Can you run in a debugger, set a breakpoint at
DescriptorPool::InternalBuildGeneratedFile(), and see what calls it, and
what the filename is each time it is called?

On Mon, Sep 8, 2008 at 6:23 AM, Mars <[EMAIL PROTECTED]> wrote:

>
> VS express 2008
>
> libprotobuf.lib and libprotobuf.dll are copy from the output of
> libprotobuf.vcproj.
> addressbook.pb.h and addressbook.pb.cc are generated by using protoc --
> cpp_out
> project -> project -> configuration properties -> c/c++ -> general ->
> Addition Include Directories "protobuf-2.0.0.beta\src"
>
> project -> project -> configuration properties -> Linker -> Input ->
> Addition Dependencies "libprotobuf.lib"
>
> == src code ==
>
> #include "stdafx.h"
> #include <iostream>
> #include <fstream>
> #include <string>
> #include "addressbook.pb.h"
> using namespace std;
>
>
> int _tmain(int argc, _TCHAR* argv[]) {
>  // Verify that the version of the library that we linked against is
>  // compatible with the version of the headers we compiled against.
>  GOOGLE_PROTOBUF_VERIFY_VERSION;
>  string filename = "t1.ss";
>
>  tutorial::AddressBook address_book;
>  tutorial::Person *person = address_book.add_person();
>
>  person->set_name("bati");
>  person->set_id(9);
>  tutorial::Person::PhoneNumber* phone_number = person->add_phone();
>  phone_number->set_number("13901099999");
>  phone_number->set_type(tutorial::Person::MOBILE);
>
>  // Write the new address book back to disk.
>  fstream output(filename.c_str(), ios::out | ios::trunc |
> ios::binary);
>  if (!address_book.SerializeToOstream(&output)) {
>    cerr << "Failed to write address book." << endl;
>    return -1;
>  }
>
>  return 0;
> }
>
>
> === error message ===
>
> libprotobuf ERROR ..\src\google\protobuf\descriptor.cc:1776] Invalid
> proto descr
> iptor for file "addressbook.proto":
> libprotobuf ERROR ..\src\google\protobuf\descriptor.cc:1779]
> addressbook.proto
> : A file with this name is already in the pool.
> libprotobuf FATAL ..\src\google\protobuf\descriptor.cc:1752] CHECK
> failed: resul
> t != NULL:
>
> This application has requested the Runtime to terminate it in an
> unusual way.
> Please contact the application's support team for more information.
>
>
>
> how to fix that?
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to