squidfunk / protobluff

A modular Protocol Buffers implementation for C
https://squidfunk.github.io/protobluff/
MIT License
88 stars 18 forks source link

Error compiling protoc-gen-chpl.cc #6

Closed Aniket21mathur closed 4 years ago

Aniket21mathur commented 4 years ago

hey @squidfunk, great work on protobluff!

I am trying to build a plugin of my own for a new language taking your code as a base. I am facing a problem in compiling protoc-gen-chpl.cc to generate protoc-gen-chpl which I can pass to the protoc compiler.

I am doing something like- g++ -I. protoc-gen-chpl.cc -lprotobuf -lpthread

but I am getting this error --->

/tmp/ccAq1MTE.o: In function `main':
protoc-gen-chpl.cc:(.text+0x3c): undefined reference to `google::protobuf::compiler::PluginMain(int, char**, google::protobuf::compiler::CodeGenerator const*)'
/tmp/ccAq1MTE.o: In function `google::protobuf::compiler::CodeGenerator::CodeGenerator()':
protoc-gen-chpl.cc:(.text._ZN6google8protobuf8compiler13CodeGeneratorC2Ev[_ZN6google8protobuf8compiler13CodeGeneratorC5Ev]+0xb): undefined reference to `vtable for google::protobuf::compiler::CodeGenerator'
/tmp/ccAq1MTE.o: In function `chapel::Generator::Generator()':
protoc-gen-chpl.cc:(.text._ZN6chapel9GeneratorC2Ev[_ZN6chapel9GeneratorC5Ev]+0x1b): undefined reference to `vtable for chapel::Generator'
/tmp/ccAq1MTE.o: In function `chapel::Generator::~Generator()':
protoc-gen-chpl.cc:(.text._ZN6chapel9GeneratorD2Ev[_ZN6chapel9GeneratorD5Ev]+0xf): undefined reference to `vtable for chapel::Generator'
protoc-gen-chpl.cc:(.text._ZN6chapel9GeneratorD2Ev[_ZN6chapel9GeneratorD5Ev]+0x22): undefined reference to `google::protobuf::compiler::CodeGenerator::~CodeGenerator()'
collect2: error: ld returned 1 exit status

I think I am not doing the linking properly, but I am not able to figure out what I am missing. It would be great if you give your opinions.

Thanks!

squidfunk commented 4 years ago

That's a good question. It seems like it's more related to linking protobuf and not this project in particular. As this project does the same, you can just check how it is done in the respective Makefile. Note, that it uses Automake, though.

squidfunk commented 4 years ago

I'm closing this issue, as it's not an issue or feature that is related to this project.

Aniket21mathur commented 4 years ago

I'm closing this issue, as it's not an issue or feature that is related to this project

Thanks for your help @squidfunk :-), I was missing the lprotoc flag, which I figured out after going through the Makefile.