gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.21k stars 484 forks source link

compilation error on apple silicon chip m1 #3210

Closed JabSYsEmb closed 1 year ago

JabSYsEmb commented 2 years ago

Hi folks,

I am trying to build gazebo project on my m1 machine since there isn't any pre-built version for m1 chip.

I was able to run cmake command with passing CMAKE_PREFIX_PATH and QWT_INCLUDE_DIR as follows:

cmake .. -DCMAKE_PREFIX_PATH=/opt/homebrew/Cellar/qt@5/5.15.3/ -DQWT_INCLUDE_DIR=/opt/homebrew/Cellar/qwt/6.2.0_1/lib/qwt.framework/Versions/6/Headers

the output:

build git:(gazebo11) ✗ cmake .. -DCMAKE_PREFIX_PATH=/opt/homebrew/Cellar/qt@5/5.15.3/ -DQWT_INCLUDE_DIR=/opt/homebrew/Cellar/qwt/6.2.0_1/lib/qwt.framework/Versions/6/Headers

-- Gazebo version 11.10.2
-- High memory tests: enabled
--

====== Finding 3rd Party Packages ======
-- Operating system is Apple MacOS X
-- Checking for module 'freeimage>=3.9.0'
--   No package 'freeimage' found
--   freeimage.pc not found, trying freeimage_include_dir and freeimage_library_dir flags.
--   Found /opt/homebrew/include/FreeImage.h
--   Looking for FreeImage.h - found
--   Looking for libfreeimage - found
-- Found Protobuf: /opt/homebrew/lib/libprotobuf.dylib (found version "3.19.4")
-- HDF5 Found
-- Checking for module 'libprofiler'
--   No package 'libprofiler' found
-- Looking for libprofiler - not found
-- Checking for module 'libtcmalloc'
--   No package 'libtcmalloc' found
-- Looking for libtcmalloc - not found
-- Looking for Simbody - found
-- Found DART: /opt/homebrew/include (Required is at least version "6.6") found components: collision-bullet collision-ode utils-urdf dart
-- Looking for DART - found
-- Using system tinyxml.
-- Using system tinyxml2.
-- Looking for libtar.h - found
-- Looking for libtar.so - found
-- Checking for modules 'playercore>=3.0;playerc++;playerwkb'
--   No package 'playercore' found
--   No package 'playerc++' found
--   No package 'playerwkb' found
--  Player not found, gazebo plugin for player will not be built.
-- Looking for GTS - found
-- Looking for libusb-1.0 - found. USB peripherals support enabled.
-- Checking for module 'OculusVR'
--   No package 'OculusVR' found
--  Oculus Rift support will be disabled.
-- Looking for ignition-math6 -- found version 6.9.2
-- Searching for dependencies of ignition-math6
-- Looking for SDFormat9  - found
-- Found Boost: /opt/homebrew/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found version "1.78.0")
-- Found Boost: /opt/homebrew/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found suitable version "1.78.0", minimum required is "1.40.0") found components: thread system filesystem program_options regex iostreams date_time
-- Looking for dlfcn.h - found
-- Looking for libdl - found
-- Could NOT find GDAL (missing: GDAL_LIBRARY GDAL_INCLUDE_DIR) (found version "GDAL_VERSION-NOTFOUND")
-- Looking for libgdal - not found
--  GDAL not found, Digital elevation terrains support will be disabled.
--  ronn not found, manpages won't be generated
-- Looking for gzip to generate manpages - found
-- Looking for libspnav and spnav.h - not found
-- Using macOS-provided uuid library
-- Looking for libgraphviz-dev - found
-- Found Protobuf: /opt/homebrew/lib/libprotobuf.dylib (found suitable version "3.19.4", minimum required is "3")
-- Looking for ignition-msgs5-config.cmake - found
-- Looking for ignition-math6-config.cmake - found
-- Looking for ignition-transport8-config.cmake - found
-- Looking for libignition-common3 - found
-- Looking for libignition-fuel_tools4 - found
-- Looking for libosvrClientKit and ClientKit.h - not found
--  OpenSource Virtual Reality (OSVR) support will be disabled.
-- Looking for qwt - found: version 6.2.0
-- ----------------------------------------

-- Looking for display capabilities
--  + found a display available ($DISPLAY is set)
--  + found a valid dri display (glxinfo)
-- Checking gazebo build type
-- Enable host CFlags
-- Could not find hardware support for SSE2 on this machine.
-- Could not find hardware support for SSE3 on this machine.
-- Could not find hardware support for SSSE3 on this machine.
-- Could not find hardware support for SSE4.1 on this machine.
--
SSE4 disabled.

-- Enable upstream CFlags
--

====== Configuring 3rd Party Packages ======
-- ----------------------------------------

-- BUILD WARNINGS
--  Player not found, gazebo plugin for player will not be built.
--  Oculus Rift support will be disabled.
--  GDAL not found, Digital elevation terrains support will be disabled.
--  ronn not found, manpages won't be generated
--  OpenSource Virtual Reality (OSVR) support will be disabled.
-- END BUILD WARNINGS

-- Custom CFlags:      -stdlib=libc++  -Wall -Wextra -Wno-long-long -Wno-unused-value -Wfloat-equal -Wshadow -Wswitch-default -Wmissing-include-dirs -pedantic
-- Build Type: RelWithDebInfo
-- Install path: /usr/local
-- tinyxml2_VERSION 9.0.0 >= 6.0.0
-- Configuration successful. Type make to compile gazebo
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/$USER/Projects/github/my-repo/gazebo/build

when I try to build the project I have the following error, is there any upcomming update solves this error?

what I can do to make the build passes for this error?

(gazebo:build) $ make
[  0%] Built target gazebo_opende_ou
[  2%] Built target gazebo_opcode
[  2%] Built target gazebo_gimpact
[ 10%] Built target gazebo_ode
Consolidate compiler generated dependencies of target gazebo_common
[ 10%] Building CXX object gazebo/common/CMakeFiles/gazebo_common.dir/AudioDecoder.cc.o
/Users/$USER/Projects/github/my-repo/gazebo/gazebo/common/AudioDecoder.cc:100:3: warning: 'av_init_packet' is deprecated [-Wdeprecated-declarations]
  av_init_packet(&packet);
  ^
/opt/homebrew/Cellar/ffmpeg/5.0.1/include/libavcodec/packet.h:505:1: note: 'av_init_packet' has been explicitly marked deprecated here
attribute_deprecated
^
/opt/homebrew/Cellar/ffmpeg/5.0.1/include/libavutil/attributes.h:100:49: note: expanded from macro 'attribute_deprecated'
#    define attribute_deprecated __attribute__((deprecated))
                                                ^
/Users/$USER/Projects/github/my-repo/gazebo/gazebo/common/AudioDecoder.cc:116:24: error: use of undeclared identifier 'avcodec_decode_audio4'; did you mean 'avcodec_decode_subtitle2'?
        bytesDecoded = avcodec_decode_audio4(this->codecCtx, decodedFrame,
                       ^~~~~~~~~~~~~~~~~~~~~
                       avcodec_decode_subtitle2
/opt/homebrew/Cellar/ffmpeg/5.0.1/include/libavcodec/avcodec.h:2531:5: note: 'avcodec_decode_subtitle2' declared here
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
    ^
/Users/$USER/Projects/github/my-repo/gazebo/gazebo/common/AudioDecoder.cc:116:62: error: cannot initialize a parameter of type 'AVSubtitle *' with an lvalue of type 'AVFrame *'
        bytesDecoded = avcodec_decode_audio4(this->codecCtx, decodedFrame,
                                                             ^~~~~~~~~~~~
/opt/homebrew/Cellar/ffmpeg/5.0.1/include/libavcodec/avcodec.h:2531:65: note: passing argument to parameter 'sub' here
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
                                                                ^
/Users/$USER/Projects/github/my-repo/gazebo/gazebo/common/AudioDecoder.cc:217:38: error: no member named 'codec' in 'AVStream'
    if (this->formatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
/Users/$USER/Projects/github/my-repo/gazebo/gazebo/common/AudioDecoder.cc:241:59: error: no member named 'codec' in 'AVStream'
  this->codecCtx = this->formatCtx->streams[audioStream]->codec;
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
/Users/$USER/Projects/github/my-repo/gazebo/gazebo/common/AudioDecoder.cc:247:17: error: assigning to 'AVCodec *' from 'const AVCodec *' discards qualifiers
  this->codec = avcodec_find_decoder(codecCtx->codec_id);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 5 errors generated.
make[2]: *** [gazebo/common/CMakeFiles/gazebo_common.dir/AudioDecoder.cc.o] Error 1
make[1]: *** [gazebo/common/CMakeFiles/gazebo_common.dir/all] Error 2
make: *** [all] Error 2
traversaro commented 2 years ago

It seems that you are trying to compile against ffmpeg 5, so you are experiencing https://github.com/osrf/gazebo/issues/3180 that should be fixed by https://github.com/osrf/gazebo/pull/3195 .

I am trying to build gazebo project on my m1 machine since there isn't any pre-built version for m1 chip.

Just FYI, on conda-forge we have non-official macOS M1 binaries: https://anaconda.org/conda-forge/gazebo .