07-15-2014 04:49 AM
I am having a lot of problems porting google protocol buffers protobuf library.
I have been following http://poweredbypenguins.wordpress.com/2013/07/27/
I am using a mac for the crosscompile (as it seems to be imposible to do in Windows) I have been able to compile and link but now I face a SIGSEV without even calling a protobuf function:
Process 426639599 (Prot_On) terminated SIGSEGV code=1 fltno=11 ip=7856bf7c(/base/lib/libcpp.so.4@_ZNKSt6locale9_G
I am sure that someone else must be using protobuf for it's application so a little love on how to compile it (or just a precompiled binary) would be great.
07-24-2014 06:28 AM
I've had a quick go at compiling protobuf. I'm not familiar with the library so please excuse me if I'm missing something obvious. From this post: https://code.google.com/p/protobuf-c/wiki/Examples
Here's the steps I went through:
1. Download and extract protobuf 2.5.0 from: https://code.google.com/p/protobuf/downloads/detai
2. Initialize a git repo within the protobuf directory - this is so you can always easily revert to the initial state of the protobuf source without all the artifacts created during the configure, make dance. As a side note, I find this to be an extremely valuable step when trying to compile any libraries from source.
git init git add --all git commit -m "Initial state"
Now you can revert using:
git clean -fd
3. Compile and install protoc for my host environment
./configure make -j8 make install #Verify protoc --version libprotoc 2.5.0
3. Now the host protoc is installed, revert the build environment. Without doing this I got linking errors during the cross compile, I think because make was trying to use the host linker rather than the BlackBerry linker.
git clean -fd
4. Set up the BlackBerry NDK environment:
5. Configure the build:
./configure --host=arm-unknown-nto-qnx8.0.0eabi --disable-protoc --with-protoc=protoc --prefix=`pwd`/build/arm-qnx
6. Make and install
make -j8 && make install
This should produce a library and headers under buid/arm-qnx. I haven't had a chance to test the library so I've attached it to this post. If you want to post some source code to test it I'd be happy to give it a whirl.
Hope that helps!
07-24-2014 07:30 AM
Thank you for your time, I was able to compile it using the same process as you did except I was using an Ubuntu machine and that I tried using static version of the lib (the .a file).
Unfortunately I face the same error with your library even as the app starts:
Process 1085784308 (Prot_On) terminated SIGSEGV code=1 fltno=11 ip=7842bf7c(/base/lib/libcpp.so.4@_ZNKSt6locale9_G
etfacetEj+0x27) mapaddr=0002bf7c. ref=00000010
I will try to generate a minimal project reproducing the issue so you can try to debug the issue.
07-24-2014 09:53 AM
Thanks for posting that. I've got it set up, and recreated my own project from scratch and both apps crash on on startup. The message I receive is different though:
Process 385605901 (ProtobufTest) terminated SIGSEGV code=1 fltno=11 ip=01277fc0(/usr/lib/ldqnx.so.2@__krait_neon_memse
I have raised this with one of our experts internally for further investigation. I'm thinking it's some basic incompatibility with the BlackBerry C library.
What is the exact configure command you're using to compile the protobuf library?
07-24-2014 10:52 AM
./configure --host=arm-unknown-nto-qnx6.5.0eabi --disable-proto-c --with-protoc=protoc --prefix=`pwd`/build/arm-qnx
That was the simplest try, I have also tried a lot of other with parameters based on different posts:
Most of my tries ended with the library not compiliing and the ones that compiled failed in the same way as posted.
I hoped that the ZeroMQ build config could fix the issue as it seems that the same error was happening with that library but I was unable to make it build.
07-24-2014 12:32 PM
Having spoken to one of my (far more experienced) colleagues it looks like the error is caused by mixing Dinkum and gcc stdc++ code. The two are not ABI compatible.
This means that the library needs to be recompiled against libcpp - the same way that ZeroMQ is compiled. I tried this and (same as you) ran into compile errors:
Configure flags (almost identical to ZeroMQ):
./configure \ --host=arm-unknown-nto-qnx8.0.0eabi \ --prefix=`pwd`/build/arm-qnx \ CC="qcc -V4.6.3,gcc_ntoarmv7le -lang-c++" \ CXX="qcc -V4.6.3,gcc_ntoarmv7le -lang-c++" \ LDFLAGS=-Wl,--no-undefined \ LIBS="-lcpp"
In file included from ./google/protobuf/stubs/hash.h:43:0, from google/protobuf/extension_set.cc:35: /Applications/Momentics.app/target_10_2_0_1155/qnx
6/usr/include/cpp/hash_map: In instantiation of 'std::_Hmap_traits<std::pair<const google::protobuf::MessageLite*, int>, google::protobuf::internal::ExtensionInfo, google::protobuf::hash<std::pair<const google::protobuf::MessageLite*, int> >, std::equal_to<std::pair<const google::protobuf::MessageLite*, int> >, false>': /Applications/Momentics.app/target_10_2_0_1155/qnx 6/usr/include/cpp/xhash:180:8: instantiated from 'std::_Hash<std::_Hmap_traits<std::pair<const google::protobuf::MessageLite*, int>, google::protobuf::internal::ExtensionInfo, google::protobuf::hash<std::pair<const google::protobuf::MessageLite*, int> >, std::equal_to<std::pair<const google::protobuf::MessageLite*, int> >, false> >' /Applications/Momentics.app/target_10_2_0_1155/qnx 6/usr/include/cpp/hash_map:79:8: instantiated from 'std::hash_map<std::pair<const google::protobuf::MessageLite*, int>, google::protobuf::internal::ExtensionInfo, google::protobuf::hash<std::pair<const google::protobuf::MessageLite*, int> >, std::equal_to<std::pair<const google::protobuf::MessageLite*, int> > >' ./google/protobuf/stubs/hash.h:172:7: instantiated from 'google::protobuf::hash_map<std::pair<const google::protobuf::MessageLite*, int>, google::protobuf::internal::ExtensionInfo>' google/protobuf/extension_set.cc:68:10: instantiated from here /Applications/Momentics.app/target_10_2_0_1155/qnx 6/usr/include/cpp/hash_map:24:3: error: no class template named 'rebind' in 'struct std::equal_to<std::pair<const google::protobuf::MessageLite*, int> >'
Searching I found someone having a similar problem cross compiling: https://groups.google.com/forum/#!msg/protobuf/7kn
It may be that we'll need to use the boost library to get this working.
07-25-2014 10:25 AM - edited 07-25-2014 10:44 AM
It seems I finally got it working, I needed to use Boost BB10 (https://github.com/blackberry/Boost) and the final configure line was a bit more complex:
./configure --host=arm-unknown-nto-qnx8.0.0eabi --disable-proto-c --with-protoc=protoc --prefix=`pwd`/build/arm-qnx CC="qcc -V4.4.2,gcc_ntoarmv7le -lang-c++" CXX="qcc -V4.4.2,gcc_ntoarmv7le -lang-c++" LDFLAGS=-Wl,--no-undefined LIBS="-lcpp -lm -lgcc" CPPFLAGS="-I/PATH_TO_BOOST/stage/include"
As a side effect I does not need any other library so it works with
LIBS += -lprotobuf
In case anyone else needs them here are the headers and the shared library: https://copy.com/VAeknvjuFPnr
Of course, thank you very much for your effort and hints doturner
07-25-2014 12:09 PM - edited 07-25-2014 12:17 PM
That is great news. Did you have to build boost? If so, what commands did you use?
Also, did you have to make any changes to the protobuf source?