fatal error: google/protobuf/port_def.inc: No such file or directory #include <google/protobuf/port_def.inc> during cross compiling an application

154 views
Skip to first unread message

Ryan Goodman

unread,
Feb 19, 2020, 5:08:42 PM2/19/20
to Protocol Buffers
Ok, when I use g++, gcc and build my application I link the protbuf library using this cmake function.

find_package(Protobuf REQUIRED)

function(missionGenerateProtobuf PROTOBUF_TARGET_NAME MSG_FILES)
  PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders ${MSG_FILES})
  add_library(${PROTOBUF_TARGET_NAME} STATIC ${ProtoSources} ${ProtoHeaders})
  target_link_libraries(${PROTOBUF_TARGET_NAME} ${PROTOBUF_LIBRARY})
endfunction(missionGenerateProtobuf PROTOBUF_TARGET_NAME MSG_FILES)

I do not get this fatal error: google/protobuf/port_def.inc: No such file or directory  #include <google/protobuf/port_def.inc> during cross compiling an application message.

However the application I am building is ultimately going to be run on an arm SBC. I use a cmake toolchain file, and try to compile in a different build directory, and then I get the error.

How do I set up protobuf in cmake for cross compiling? I have not been able to find anything on the internet, and I know it has to be possible. Do I need to cross-compile the protoc compiler first, and then use that cross-compile the application?

Thank you for your help.


The V

unread,
Mar 5, 2020, 12:44:50 AM3/5/20
to Protocol Buffers
Reply all
Reply to author
Forward
0 new messages