Hello!
I want to create static lib, which exports wrapper of prtobuf-generated
class, but encountered such a problem:
1. building static library (Msg):
//msgbuf.proto------------------------
message MsgBuf{
required int32 val = 1;
}
//msg.h-----------------------------------
class MsgBuff;
class Msg{
MsgBuff *ioBuf;
public:
int value() const;
};
//msg.cpp--------------------------------
#include "msg.h"
#include "msgbuf.pb.h"
Msg::Msg{
ioBuf = new MsgBuf;
}
int Msg::value() const {
return ioBuf->val();
}
thus lib project includes:
HEADERS += msg.h msgbuf.pb.h
SOURCES += msg.cpp msgbuf.pb.cc
INCLUDEPATH += path_to_protobuf_include
LIBS += -Lpath_to_protobuf_lib -lprotobuf
static library compilation is successful.
2. Further, if the resulting static library to linked to test app
//main.cpp--------------------------------
#include "msg.h"
int main(){
Msg m;
return 0;
}
lib project includes:
HEADERS+= msg.h
SOURCES += main.cpp
LIBS += -Lpath_to_libMsg -lMsg
then I get a long list of errors:
./libMsg.a(msgbuf.pb.o): In function
`Z34protobuf_AssignDesc_msgbuf_2eprotov':
path_to_Msg/msgbuf.pb.cc:29: undefined reference to
`google::protobuf::DescriptorPool::generated_pool()'
path_to_Msg /msgbuf.pb.cc:29: undefined reference to
`google::protobuf::DescriptorPool::FindFileByName(std::string const&) const'
path_to_Msg /msgbuf.pb.cc:30: undefined reference to
`google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel,
char const*, int)'
path_to_Msg /msgbuf.pb.cc:30: undefined reference to
`google::protobuf::internal::LogMessage::operator<<(char const*)'
....
....
and so on...
please help me solve this problem.
Sorry for my English.
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to [email protected].
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.