link issue with proto in different project

149 views
Skip to first unread message

yang yu

unread,
Nov 5, 2010, 4:15:28 AM11/5/10
to prot...@googlegroups.com
I'm working on windows, some of my projects are dlls.
i need to add __declspec dllexport/dllimport symbol with the function or variables to use the project as dll.
but when i use protoc generate the source for the proto file,  of course they don't have the dllexport/dllimport symbol.
the problem is after build dll A(have a proto), when i build B link the project A, i got some link error like this:
error LNK2019:  unresolved external symbol "void PB:protobuf_AddDesc_Point2df_2eproto(void)""..................

because the function "void PB:protobuf_AddDesc_Point2df_2eproto(void)" in dll A didn't export,
so the project B link faild.
anything help would be wonderful.

-----------------------------------------------the situation like this-------------------------------------------
in DLL-A, have a proto like this:
---------point.proto---------
package PB;

message Point2df
{
required float x = 1;
required float y = 2;
}

in DLL-B, have a proto like this;
---------path.proto---------
package PB;
import "point.proto";
message Path
{
repeated Point2df points = 1;
}

Kenton Varda

unread,
Nov 9, 2010, 6:27:43 PM11/9/10
to yang yu, prot...@googlegroups.com
There is a command-line option to add an export macro to all definitions.  Use something like:

  protoc --cpp_out=dllexport_decl=MY_EXPORT_MACRO:outdir

However, be very careful when passing protobuf objects across a DLL boundary.  The code on both sides must be dynamically linked against the same version of the C runtime, otherwise you run into all kinds of binary compatibility and heap issues.  See vsprojects/readme.txt for more information.

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

Reply all
Reply to author
Forward
0 new messages