Reputation: 436
I'm feeling a bit thick, but when I run through even basic examples provided on http://code.google.com/p/protobuf-c/wiki/Examples, I keep getting the following build errors:
/tmp/cc19catp.o: In function `main': packit.c:(.text+0x13): undefined reference to `amessage__descriptor' packit.c:(.text+0xb6): undefined reference to `amessage__get_packed_size' packit.c:(.text+0xdb): undefined reference to `amessage__pack' collect2: ld returned 1 exit status
I'm compiling with the following command:
gcc -o pack -lprotobuf-c packit.c
Anyone else have this problem? I feel I'm missing something basic.
Upvotes: 0
Views: 2325
Reputation: 205014
gcc -o pack packit.c amessage.pb-c.c -lprotobuf-c
You must compile and link the proto-c
-generated code.
Also, in general, when foo
depends on bar
, foo
should precede bar
in the linker command.
Upvotes: 2