We are working on a project, where we need protbuf in order to deserialize some specific messages received over tcp.
First, we want to build for the host - but even this is not working like expected.
Build LibProtobuf on Host
We are using cmake to build protobuf on the host machine.
Excerpt from our CMakeCache.txt:
CMAKE_BUILD_TYPE:STRING=Release
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
CMAKE_INSTALL_PREFIX:PATH=/home/ubuntu/Projects/Protobuf/INSTALL_SO
protobuf_BUILD_SHARED_LIBS:BOOL=ON
Use LibProtobuf within Driveworks
To see if building is working, we hardcoded the CMakeLists changes. This will be resolved lateron.
Changed the default CMakeLists.txt of the render example app to include protobuf:
include_directories("/home/ubuntu/Projects/Protobuf/INSTALL_SO/include")
Also we added the lib to the libraries:
set(LIBRARIES
dw_samples_framework
${Driveworks_LIBRARIES}
/home/ubuntu/Projects/JohannHaselberger/testBuff/INSTALL/lib/libprotobuf.so
)
And finally added the Protobuf generated files:
set(SOURCES
main.cpp
testPB.pb.h
testPB.pb.cc
)
Building
The CMake command runs perfectly but make stops with this error message:
/home/ubuntu/Projects/Protobuf/INSTALL_SO/lib/libprotobuf.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
Side note
We actually are doing the same procedure with libzmq (build libzmq with cmake and inlcude it the same way as protbuf). Here, building works like a charm.
JHaselberger,
The default protobuf lib on driveworks is a static lib(.a) but not a shared one(.so).
How about using static one for your app?
We made some progress:
Still using protobuf shared libs, we can build for the host after deleting both build-host and build-target folders and updating the CMakeLists.txt hardcoded to:
# FIND PROTOBUF -- there are different versions for target and host
message("-- Finding PROTOBUF")
if(LINUX)
message("-- Use PROTOBUF host build")
set(DW_Protobuf_LIBRARY "/home/ubuntu/Projects/JohannHaselberger/Protobuf/build-host/INSTALL/lib/libprotobuf.so")
set(DW_Protobuf_INCLUDE "/home/ubuntu/Projects/JohannHaselberger/Protobuf/build-host/INSTALL/include")
elseif(VIBRANTE)
message("-- Use PROTOBUF target build")
set(DW_Protobuf_LIBRARY
"/home/ubuntu/Projects/JohannHaselberger/Protobuf/build-target/INSTALL/lib/libprotobuf.so"
"/home/ubuntu/Projects/JohannHaselberger/Protobuf/build-target/INSTALL/lib/libz.so.1")
set(DW_Protobuf_INCLUDE "/home/ubuntu/Projects/JohannHaselberger/Protobuf/build-target/INSTALL/include")
endif()
But for the target we are getting some strange errors:
In file included from /home/ubuntu/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/include/EGL/eglplatform.h:119:0,
from /home/ubuntu/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/include/EGL/egl.h:39,
from /usr/local/driveworks-0.6/targets/aarch64-linux/include/dw/core/EGL.h:49,
from /home/ubuntu/Projects/JohannHaselberger/Driveworks/samples/src/framework/../framework/Window.hpp:34,
from /home/ubuntu/Projects/JohannHaselberger/Driveworks/samples/src/framework/../framework/WindowGLFW.hpp:34,
from /home/ubuntu/Projects/JohannHaselberger/Driveworks/samples/src/zmq/main.cpp:42:
/home/ubuntu/Projects/JohannHaselberger/Protobuf/build-target/INSTALL/include/google/protobuf/stubs/logging.h:66:7: error: expected identifier before 'int'
class Status;
^
/home/ubuntu/Projects/JohannHaselberger/Protobuf/build-target/INSTALL/include/google/protobuf/stubs/logging.h:66:7: error: multiple types in one declaration
In file included from /home/ubuntu/Projects/JohannHaselberger/Protobuf/build-target/INSTALL/include/google/protobuf/stubs/common.h:50:0,
from /home/ubuntu/Projects/JohannHaselberger/Driveworks/samples/src/zmq/imagePB.pb.h:9,
from /home/ubuntu/Projects/JohannHaselberger/Driveworks/samples/src/zmq/main.cpp:62:
/home/ubuntu/Projects/JohannHaselberger/Protobuf/build-target/INSTALL/include/google/protobuf/stubs/logging.h:90:32: error: expected ')' before '::' token
LogMessage& operator<<(const ::google::protobuf::util::Status& status);
^
/home/ubuntu/Projects/JohannHaselberger/Protobuf/build-target/INSTALL/include/google/protobuf/stubs/logging.h:90:32: error: 'google::protobuf::internal::LogMessage& google::protobuf::internal::LogMessage::operator<<(...)' must not have variable number of arguments
/home/ubuntu/Projects/JohannHaselberger/Protobuf/build-target/INSTALL/include/google/protobuf/stubs/logging.h:90:26: error: expected ';' at end of member declaration
LogMessage& operator<<(const ::google::protobuf::util::Status& status);
^
In file included from /home/ubuntu/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/include/EGL/eglplatform.h:119:0,
from /home/ubuntu/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/include/EGL/egl.h:39,
from /usr/local/driveworks-0.6/targets/aarch64-linux/include/dw/core/EGL.h:49,
from /home/ubuntu/Projects/JohannHaselberger/Driveworks/samples/src/framework/../framework/Window.hpp:34,
from /home/ubuntu/Projects/JohannHaselberger/Driveworks/samples/src/framework/../framework/WindowGLFW.hpp:34,
from /home/ubuntu/Projects/JohannHaselberger/Driveworks/samples/src/zmq/main.cpp:42:
/home/ubuntu/Projects/JohannHaselberger/Protobuf/build-target/INSTALL/include/google/protobuf/stubs/logging.h:90:58: error: expected unqualified-id before 'int'
LogMessage& operator<<(const ::google::protobuf::util::Status& status);