Re: Howto build protobuf not as library, but directly linking object files?

2009-07-10 Thread bart van deenen



On Jul 9, 8:54 pm, Alex Black a...@alexblack.ca wrote:
 Hey Bart, I'm not sure I'm seeing the full details of your situation,

 But on windows I compiled a library libprotobuf.lib, and linked to it
 statically, meaning it gets built into the exe (or dll) you're building.
 (I built 2 actually, a  release one and a debug one).

That's how it works on Linux. Here's the problems we're having on
Windows. We're building protoc with the mingw compiler system included
in the Qt 4.5.1 SDK. This doesn't generate .lib files, but .la files
and .a files. The .a is a static archive. When I run 'nm
libprotobuf.a' I get all the typical protobuf function definitions, so
that looks ok.

However, when I try to build my application with -Lpath/to/
libprotobuf.a I get hundreds of linker errors, complaining about
undefined references to any of the google protocol functions.

I'm using the same mingw compiler to build my Qt application, so that
is not the problem.

Anyway, I'm still struggling with this stuff, and since no one at my
company knows anything about C++ on Windows, it's a hassle. So that's
why I just try to circumvent the problem by just linking the object
files directly.
--~--~-~--~~~---~--~~
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 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~--~~~~--~~--~--~---



Re: Howto build protobuf not as library, but directly linking object files?

2009-07-10 Thread Kenton Varda
On Fri, Jul 10, 2009 at 3:12 AM, bart van deenen
bart.vandee...@gmail.comwrote:

 However, when I try to build my application with -Lpath/to/
 libprotobuf.a I get hundreds of linker errors, complaining about
 undefined references to any of the google protocol functions.


You need to use:

  -Lpath/to/lib/dir -lprotobuf

The -L flag adds a directory which will be searched for libraries, whereas
the -l flag says to link against a particular library.  The compiler
automatically prefixes the library name with lib and suffixes it with
.a.

Note that I test every release on MinGW.  You can use MSYS to invoke the
included configure script and makefiles, to build it just like you would on
any Unix system.




 I'm using the same mingw compiler to build my Qt application, so that
 is not the problem.

 Anyway, I'm still struggling with this stuff, and since no one at my
 company knows anything about C++ on Windows, it's a hassle. So that's
 why I just try to circumvent the problem by just linking the object
 files directly.
 


--~--~-~--~~~---~--~~
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 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~--~~~~--~~--~--~---



Re: Howto build protobuf not as library, but directly linking object files?

2009-07-10 Thread bart van deenen

Thank you thank you thank you! You're my savior

:-)
--~--~-~--~~~---~--~~
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 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~--~~~~--~~--~--~---



RE: intermittent issue with encode (version 2.0.3)

2009-07-10 Thread Rizzuto, Raymond
Is there something I need to do in the application to cause that to happen 
before I've spun off multiple threads?  Currently I spin up threads, which then 
start making calls to fill in and then encode google protobuffers.


From: Kenton Varda [mailto:ken...@google.com]
Sent: Thursday, July 09, 2009 6:05 PM
To: Rizzuto, Raymond
Cc: protobuf@googlegroups.com
Subject: Re: intermittent issue with encode (version 2.0.3)

As the comment says, the first call will always occur at startup time when 
there is only one thread anyway, so it's perfectly safe.  The parenthetical 
about GCC4 is just an aside.
On Thu, Jul 9, 2009 at 2:47 PM, Rizzuto, Raymond 
raymond.rizz...@sig.commailto:raymond.rizz...@sig.com wrote:

I am a bit nervous about the GCC4 comment in GeneratedMessageFactory::singleton 
 (message.cc):



  // No need for thread-safety here because this will be called at static

  // initialization time.  (And GCC4 makes this thread-safe anyway.)



I'm using gcc 3.3.3.



The singleton object in GeneratedMessageFactory::singleton, is a local static 
of non-POD type.  The C++ standard says:



An implementation is permitted to perform

early initialization of other local objects with static storage duration under 
the same conditions that an

implementation is permitted to statically initialize an object with static 
storage duration in namespace scope

(3.6.2). Otherwise such an object is initialized the first time control passes 
through its declaration; such an

object is considered initialized upon the completion of its initialization.



I don't think the language standard addresses what first time control passes 
through its declaration means when two threads call the function 
simultaneously.  Perhaps gcc4 provides features that make that safe.  I don't 
know if that is something that can be relied on in all compilers, however.



Ray





From: Kenton Varda [mailto:ken...@google.commailto:ken...@google.com]
Sent: Thursday, July 09, 2009 5:08 PM

To: Rizzuto, Raymond
Cc: protobuf@googlegroups.commailto:protobuf@googlegroups.com
Subject: Re: intermittent issue with encode (version 2.0.3)



I suppose you could also temporarily edit the header file.

On Thu, Jul 9, 2009 at 2:05 PM, Rizzuto, Raymond 
raymond.rizz...@sig.commailto:raymond.rizz...@sig.com wrote:

I'm trying to, without success.   Breakpoints in header files, at least with 
the version of tools I have, don't work very well.





From: Kenton Varda [mailto:ken...@google.commailto:ken...@google.com]
Sent: Thursday, July 09, 2009 5:02 PM
To: Rizzuto, Raymond
Cc: protobuf@googlegroups.commailto:protobuf@googlegroups.com
Subject: Re: intermittent issue with encode (version 2.0.3)



Run in a debugger and set a breakpoint at wire_format_inl.h:289.

On Thu, Jul 9, 2009 at 1:56 PM, Rizzuto, Raymond 
raymond.rizz...@sig.commailto:raymond.rizz...@sig.com wrote:

I think I have an error in my code (C++) that only occurs when I have multiple 
threads, and a lot of message volume.   Even then, I can run the same test many 
times, but only get a failure on some runs.  With 7 threads running on a 4 core 
machine, and generating 480384 google protocol buffer messages, I get 33 errors 
like this to stdout:



libprotobuf ERROR 
/siglinux/tc/sles9sp4_gcc-3.3.3_i686/sig1/protobuf-2.0.3/include/google/protobuf/wire_format_inl.h:289]
 Encountered string containing invalid UTF-8 data while serializing protocol 
buffer. Strings must contain only UTF-8; use the 'bytes' type for raw bytes.



I believe that the data is in error since I get similar errors decoding the 
messages:



libprotobuf ERROR 
/siglinux/tc/sles9sp4_gcc-3.3.3_i686/sig1/protobuf-2.0.3/include/google/protobuf/wire_format_inl.h:138]
 Encountered string containing invalid UTF-8 data while parsing protocol 
buffer. Strings must contain only UTF-8; use the 'bytes' type for raw bytes.



Is there any way that I can check for this at run time so that I can print out 
more context?  I do call IsInitialized before serializing, but that doesn't 
check for this case.



I am running on SLES9SP4, using gcc 3.3.3 as the compiler.



Ray





Ray Rizzuto

raymond.rizz...@sig.commailto:raymond.rizz...@sig.com

Susquehanna International Group

(610)747-2336 (W)

(215)776-3780 (C)









IMPORTANT: The information contained in this email and/or its attachments is 
confidential. If you are not the intended recipient, please notify the sender 
immediately by reply and immediately delete this message and all its 
attachments. Any review, use, reproduction, disclosure or dissemination of this 
message or any attachment by an unintended recipient is strictly prohibited. 
Neither this message nor any attachment is intended as or should be construed 
as an offer, solicitation or recommendation to buy or sell any security or 
other financial instrument.