Dear all, I'm having problems with statically linked executables that use protocol buffers. I suspect the problem may be related to incompatibility between std::string implementation used to compile the library vs. current. If that's the case, the problem would likely go away with recompilation of the protocol buffer libraries (protobuf-lite is also exposing the same problem).
I have attached a test case as you requested. the example program compiles two variants - one dynamically linked (works fine) and one statically linked that crashes upon first attempt to serialize the protocol buffer. It would be great if someone could take a look and possibly rebuild the static libraries for protocol buffers. Best regards, Tomasz -------- example.proto ------------ syntax = "proto2"; package example; message ExampleMsg { optional int32 argc = 1; optional string argv0 = 2; }; -------- main.cc ------------ #include <iostream> #include <string> #include "example.pb.h" int main(int argc, char** argv) { example::ExampleMsg message; message.set_argc(argc); message.set_argv0(argv[0]); std::cout << "Serializing protocol buffer." << std::endl; std::string serialized; message.SerializeToString(&serialized); // static variant crashes here. std::cout << "Serialized length: " << serialized.length() << std::endl; message.Clear(); std::cout << "Deserializing protocol buffer." << std::endl; message.ParseFromString(serialized); // static variant also crashes here. std::cout << "Deserialized content: argc=" << message.argc() << ", argv0=" << message.argv0(); return 0; } -------- Makefile ------------ CFLAGS += -Wall CXXFLAGS := $(CFLAGS) CC = g++ LIBS = -lprotobuf.dll all: clean example example-bug example.pb.cc: example.proto protoc --cpp_out=. $^ clean: rm -f *.o *.pb.* *.exe* example: example.pb.o main.o $(CC) $(CFLAGS) $^ -o $@ $(LIBS) example-bug: example.pb.o main.o $(CC) $(CFLAGS) -static $^ -o $@ $(LIBS) -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple