Using Library Without Download
I am trying to use the google protobuf library without having to download the whole library and run through ./configure, make, make check, ... I am currently putting the protoc executable in /usr/local/bin and the google folder in /usr/local/include. When I try running my program, I get this error
/usr/local/bin/protoc: 1: /usr/local/bin/protoc: Syntax error: "(" unexpected
What am I doing wrong? What can I do to get my program working correctly? My program is somewhat similar to the example code in C++. I have also tested using the example code given and the same problem occurs.
I am obtaining the protoc executable and the google folder from "protoc-3.3.0-linux-x86_32.zip". I am working on a Raspberry Pi 3 Model B.
How did you invoke protoc? And how does your .proto file look like?
I am calling protoc by calling make in the examples folder. My .proto file is also the same one from the examples folder. I am now just trying to get the example working. I am starting with a new machine, copying the "examples" folder over, then putting the protoc executable in /usr/local/bin and the google folder in /usr/local/include.
I wish to just use the examples add_person_cpp and list_people_cpp for now, without having to download and run the whole protobuf library.
Can you try this in the examples directory and report back what you get:
protoc --cpp_out=. addressbook.proto
bash: /usr/local/bin/protoc: cannot execute binary file: Exec format error
What could this mean?
It means the protoc binary you downloaded is not the correct format for your system. Try:
$ file /usr/local/bin/protoc
$ uname -a
The above 2 commands should show you the type of the binary you downloaded and the info of your operating system.
It seems you are using C++. I suggest you build the protobuf library from source code. It's actually quite easy. Just download https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz, extract it and run ./configure && make && sudo make install. It should only take a couple of minutes.
On a Raspberry Pi, running make takes at least 45 minutes. I want to be able to distribute it without everyone having to run make. I am currently running armv7l, which is a 32-bit system. I have also downloaded the 32-bit version of protoc. I have tried using the protoc that I created on a previous version by running make on the Raspberry Pi and that also has the same error.
The protoc binary we put up on the release page is for x86/x64 only. For arm you have to build it from source code. I think you can build it once and store/distribute the binary you build for others to use. Cross-compiling may also be an option.
I have used the same protoc and now I get a different error.
protoc: error while loading shared libraries: libprotobuf.so.13: cannot open shared object file: No such file or directory
libprotobuf.so.13 is a linker to libprotobuf.so.13.0.0, where both files are in /usr/local/lib. Where is it looking for this file?
So you are using the protoc binary and protobuf library you built from source code? Try if "sudo ldconfig" helps.
I have tried that
See: https://stackoverflow.com/questions/25518701/protobuf-cannot-find-shared-libraries
It worked!!! Thank you very much. You have been extremely helpful.
In the end I was copying over "libprotobuf.so.13". This created an error because "sudo ldconfig" is suppose to create this file based off of "libprotobuf.so.13.0.0".