OpenLightingProject / ola

The Open Lighting Architecture - The Travel Adaptor for the Lighting Industry
https://www.openlighting.org/ola/
Other
647 stars 205 forks source link

Cross Compilation Causes protoc Missing Error #1864

Open DaAwesomeP opened 1 year ago

DaAwesomeP commented 1 year ago

Hello!

I am able to compile fine for x86_64 on this system. When I try to cross-compile for aarch64, Autoconf is refusing to use the header files for protoc that are definitely present:

./configure --build x86_64-linux-gnu --host aarch64-linux-gnu CPPFLAGS=-Wno-deprecated-declarations
checking for libprotobuf... yes
checking for protoc... /usr/bin/protoc
checking protoc version... 3.12.4
checking google/protobuf/compiler/command_line_interface.h usability... no
checking google/protobuf/compiler/command_line_interface.h presence... yes
configure: WARNING: google/protobuf/compiler/command_line_interface.h: present but cannot be compiled
configure: WARNING: google/protobuf/compiler/command_line_interface.h:     check for missing prerequisite headers?
configure: WARNING: google/protobuf/compiler/command_line_interface.h: see the Autoconf documentation
configure: WARNING: google/protobuf/compiler/command_line_interface.h:     section "Present But Cannot Be Compiled"
configure: WARNING: google/protobuf/compiler/command_line_interface.h: proceeding with the compiler's result
configure: WARNING:     ## --------------------------------------------- ##
configure: WARNING:     ## Report this to open-lighting@googlegroups.com ##
configure: WARNING:     ## --------------------------------------------- ##
checking for google/protobuf/compiler/command_line_interface.h... no
configure: error: Cannot find the protoc header files

This appears to be coming from this auto-generated bit in ola.m4:

if test "$with_ola_protoc_plugin" != "no"; then
  OLA_PROTOC="$PROTOC --plugin=protoc-gen-cppservice=${with_ola_protoc_plugin}";
  echo "set ola_protoc to $OLA_PROTOC"
else
  OLA_PROTOC="$PROTOC --plugin=protoc-gen-cppservice=\$(top_builddir)/protoc/ola_protoc_plugin${EXEEXT}";
  AC_CHECK_HEADER(
      [google/protobuf/compiler/command_line_interface.h],
      [],
      AC_MSG_ERROR([Cannot find the protoc header files]))
  SAVED_LIBS=$LIBS
  LIBS="$LIBS -lprotoc"
  AC_LINK_IFELSE(
    [AC_LANG_PROGRAM([#include <google/protobuf/compiler/command_line_interface.h>],
      [google::protobuf::compiler::CommandLineInterface cli])],
    [TEST_LIBS="$TEST_LIBS -lprotoc"] [],
    [AC_MSG_ERROR([cannot find libprotoc])])
  LIBS=$SAVED_LIBS
fi
AC_SUBST([OLA_PROTOC])
AM_CONDITIONAL(BUILD_OLA_PROTOC_PLUGIN, test "${with_ola_protoc_plugin}" = "no")
])

I also tried this, but make all then fails because the protoc/ola_protoc_plugin executable doesn't actually get compiled:

./configure --build x86_64-linux-gnu --host aarch64-linux-gnu --with-protoc=/usr/bin/protoc --with-ola-protoc-plugin=protoc/ola_protoc_plugin CPPFLAGS=-Wno-deprecated-declarations
$ make all -j2
/usr/bin/protoc --plugin=protoc-gen-cppservice=protoc/ola_protoc_plugin --cppservice_out ./common/protocol --proto_path ./common/protocol ./common/protocol/Ola.proto
/usr/bin/protoc --plugin=protoc-gen-cppservice=protoc/ola_protoc_plugin --cppservice_out ./common/protocol --proto_path ./common/protocol ./common/protocol/Ola.proto
[libprotobuf WARNING google/protobuf/compiler/parser.cc:648] No syntax specified for the proto file: Ola.proto. Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)
[libprotobuf WARNING google/protobuf/compiler/parser.cc:648] No syntax specified for the proto file: Ola.proto. Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)
protoc/ola_protoc_plugin: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--cppservice_out: protoc-gen-cppservice: Plugin failed with status code 1.
make: *** [Makefile:19184: common/protocol/OlaService.pb.h] Error 1
make: *** Waiting for unfinished jobs....
protoc/ola_protoc_plugin: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--cppservice_out: protoc-gen-cppservice: Plugin failed with status code 1.
make: *** [Makefile:19184: common/protocol/OlaService.pb.cpp] Error 1
DaAwesomeP commented 1 year ago

Seeing the same thing when trying to cross compile the Debian package:

2023-06-19T16:57:36.8786643Z checking for libprotobuf... yes
2023-06-19T16:57:36.8789494Z checking for protoc... /usr/bin/protoc
2023-06-19T16:57:36.8982881Z checking protoc version... 3.12.4
2023-06-19T16:57:37.3440614Z checking google/protobuf/compiler/command_line_interface.h usability... no
2023-06-19T16:57:37.4399146Z configure: WARNING: google/protobuf/compiler/command_line_interface.h: present but cannot be compiled
2023-06-19T16:57:37.4399608Z checking google/protobuf/compiler/command_line_interface.h presence... yes
2023-06-19T16:57:37.4401186Z configure: WARNING: google/protobuf/compiler/command_line_interface.h:     check for missing prerequisite headers?
2023-06-19T16:57:37.4403436Z configure: WARNING: google/protobuf/compiler/command_line_interface.h: see the Autoconf documentation
2023-06-19T16:57:37.4405908Z configure: WARNING: google/protobuf/compiler/command_line_interface.h:     section "Present But Cannot Be Compiled"
2023-06-19T16:57:37.4408516Z configure: WARNING: google/protobuf/compiler/command_line_interface.h: proceeding with the compiler's result
2023-06-19T16:57:37.4427314Z configure: WARNING:     ## --------------------------------------------- ##
2023-06-19T16:57:37.4427779Z configure: WARNING:     ## Report this to open-lighting@googlegroups.com ##
2023-06-19T16:57:37.4428208Z configure: WARNING:     ## --------------------------------------------- ##
2023-06-19T16:57:37.4437181Z checking for google/protobuf/compiler/command_line_interface.h... no
2023-06-19T16:57:37.4441136Z configure: error: Cannot find the protoc header files
2023-06-19T16:57:37.5060568Z    tail -v -n \+0 config.log
2023-06-19T16:57:37.5184948Z dh_auto_configure: error: ./configure --build=x86_64-linux-gnu --prefix=/usr --includedir=\${prefix}/include --mandir=\${prefix}/share/man --infodir=\${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --disable-option-checking --disable-silent-rules --libdir=\${prefix}/lib/aarch64-linux-gnu --libexecdir=\${prefix}/lib/aarch64-linux-gnu --disable-maintainer-mode --disable-dependency-tracking --host=aarch64-linux-gnu --enable-python-libs --enable-rdm-tests "CXXFLAGS=-Wno-error=deprecated-declarations -Wno-error=unused-parameter" pythondir=/usr/lib/python3/dist-packages returned exit code 1
2023-06-19T16:57:37.5186096Z make[1]: *** [debian/rules:17: override_dh_auto_configure] Error 25
2023-06-19T16:57:37.5186394Z make: *** [debian/rules:14: build] Error 2
2023-06-19T16:57:37.5186835Z dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2
peternewman commented 1 year ago

What does config.log say @DaAwesomeP ? Given it's present but can't be compiled, it could also be #1879 but seems unlikely if it works during a native build...

Have you seen this: https://wiki.openlighting.org/index.php/Cross_Compiling_OLA

I think you effectively have to have two sets of headers and protoc/protobuf, you need one on the base system, so you can compile the ola_protoc_plugin, and then you need one on the cross-compile so you can compile the main codebase.