trilliumeng / orion-sdk

Public SDK and ICD for Trillium Engineering's Orion Gimbals.
http://www.trilliumeng.com
MIT License
15 stars 15 forks source link

Failures, errors and solutions to build Orion-SDK on Ubuntu 22.04 on Raspberry Pi 4 #24

Open chababster opened 3 weeks ago

chababster commented 3 weeks ago

UBUNTU 22.04 LTS

Error from make

Platform: Raspberry Pi 4 2gb RAM running Ubuntu 22.04 aarch64 GNU/Linux Issue: Unable to execute make successfully in either Utils or Communications folder. Error: Error from running make in orion-sdk/Communications/:

fatal error: OrionPublicPacket.h: No such file or directory

Cause: Headers and source code have not been generated yet for this clone Solution: Execute GenerateOrionPublicPacket.sh to generate necessary files

Error from GenerateOrionPublicPacket.sh in ./orion-sdk/

Error from running GenerateOrionPublicPacket.sh in ./orion-sdk/:

error while loading shared libraries: libicui18n.so.60: cannot open shared object file: No such file or directory

Cause: libicui18n.so.60 is specific to ProtoGen built for Ubuntu 18; therefore, we can't compile with it on new platforms Solution: Regenerate ProtoGen binary for Ubuntu 22

Generating new ProtoGen binary

Make backup of original ProtoGen binary in the cloned orion-sdk folder

cp <local_orion_sdk_git_folder>/ProtoGen/Linux/aarch64/ProtoGen <local_orion_sdk_git_folder>/ProtoGen/Linux/aarch64/ProtoGen.orig

Clone source for, and generate new, ProtoGen binary

git clone https://github.com/billvaglienti/ProtoGen.git
cd ProtoGen
sudo apt install qtbase5-dev qt5-qmake
qmake && make

Copy new ProtoGen binary to Orion SDK folder

cp <local_protogen_git_folder>/ProtoGenInstall/ProtoGen <local_orion_sdk_git_folder>/ProtoGen/Linux/aarch64/

Generating new Public Packets

Now we can generate the Public Packets with the script

./<local_orion_sdk_git_folder>/GenerateOrionPublicPacket.sh

Run make again in the library folders Error: Some lines in the generated header and source code are not formatted as they should be. Some comments are not commented out and some variables did not get updated Solution: Fix comments and update variables where needed

OrionPublicPacket.h

OrionPublicPacket.c

Running make in library folders

Now we can make the libraries for the Orion SDK

cd <orion_sdk>/Communications && make
cd <orion_sdk>/Util && make
cd <orion_sdk>/Examples && make
chababster commented 3 weeks ago

The same initial error occurs when trying to build on Raspbian 12 on a Raspberry Pi 4. This solution works for Raspbian 12 as well, but fails to build VideoPlayer when executing make inside Examples dir

...
make[1]: Entering directory '/home/pi/Documents/git/orion-sdk/Examples/SendConfig'
make[1]: Leaving directory '/home/pi/Documents/git/orion-sdk/Examples/SendConfig'
make[1]: Entering directory '/home/pi/Documents/git/orion-sdk/Examples/TrackerFeed'
make[1]: Leaving directory '/home/pi/Documents/git/orion-sdk/Examples/TrackerFeed'
make[1]: Entering directory '/home/pi/Documents/git/orion-sdk/Examples/TrackSize'
make[1]: Leaving directory '/home/pi/Documents/git/orion-sdk/Examples/TrackSize'
make[1]: Entering directory '/home/pi/Documents/git/orion-sdk/Examples/UserData'
make[1]: Leaving directory '/home/pi/Documents/git/orion-sdk/Examples/UserData'
make[1]: Entering directory '/home/pi/Documents/git/orion-sdk/Examples/VideoPlayer'
KlvParser.c: In function ‘KlvPrintData’:
KlvParser.c:326:34: warning: unused variable ‘j’ [-Wunused-variable]
  326 |                 uint32_t Length, j;
      |                                  ^
StreamDecoder.c: In function ‘StreamOpen’:
StreamDecoder.c:32:5: warning: implicit declaration of function ‘avcodec_register_all’ [-Wimplicit-function-declaration]
   32 |     avcodec_register_all();
      |     ^~~~~~~~~~~~~~~~~~~~
StreamDecoder.c:33:5: warning: implicit declaration of function ‘av_register_all’ [-Wimplicit-function-declaration]
   33 |     av_register_all();
      |     ^~~~~~~~~~~~~~~
StreamDecoder.c:68:70: error: ‘AVStream’ has no member named ‘codec’
   68 |     pCodec = avcodec_find_decoder(pInputContext->streams[VideoStream]->codec->codec_id);
      |                                                                      ^~
StreamDecoder.c:90:94: error: ‘AVStream’ has no member named ‘codec’
   90 |             AVStream *pStream = avformat_new_stream(pOutputContext, pInputContext->streams[i]->codec->codec);
      |                                                                                              ^~
StreamDecoder.c:91:13: warning: implicit declaration of function ‘avcodec_copy_context’; did you mean ‘avcodec_free_context’? [-Wimplicit-function-declaration]
   91 |             avcodec_copy_context(pStream->codec, pInputContext->streams[i]->codec);
      |             ^~~~~~~~~~~~~~~~~~~~
      |             avcodec_free_context
StreamDecoder.c:91:41: error: ‘AVStream’ has no member named ‘codec’
   91 |             avcodec_copy_context(pStream->codec, pInputContext->streams[i]->codec);
      |                                         ^~
StreamDecoder.c:91:75: error: ‘AVStream’ has no member named ‘codec’
   91 |             avcodec_copy_context(pStream->codec, pInputContext->streams[i]->codec);
      |                                                                           ^~
StreamDecoder.c:95:24: error: ‘AVStream’ has no member named ‘codec’
   95 |                 pStream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
      |                        ^~
StreamDecoder.c:110:5: warning: ‘av_init_packet’ is deprecated [-Wdeprecated-declarations]
  110 |     av_init_packet(&Packet);
      |     ^~~~~~~~~~~~~~
In file included from /usr/include/aarch64-linux-gnu/libavcodec/avcodec.h:45,
                 from FFmpeg.h:4,
                 from StreamDecoder.c:3:
/usr/include/aarch64-linux-gnu/libavcodec/packet.h:512:6: note: declared here
  512 | void av_init_packet(AVPacket *pkt);
      |      ^~~~~~~~~~~~~~
StreamDecoder.c: In function ‘StreamProcess’:
StreamDecoder.c:173:13: warning: implicit declaration of function ‘avcodec_decode_video2’; did you mean ‘avcodec_decode_subtitle2’? [-Wimplicit-function-declaration]
  173 |             avcodec_decode_video2(pCodecContext, pFrame, &NewVideo, &Packet);
      |             ^~~~~~~~~~~~~~~~~~~~~
      |             avcodec_decode_subtitle2
StreamDecoder.c:319:9: warning: implicit declaration of function ‘av_free_packet’; did you mean ‘av_get_packet’? [-Wimplicit-function-declaration]
  319 |         av_free_packet(&Packet);
      |         ^~~~~~~~~~~~~~
      |         av_get_packet
StreamDecoder.c: In function ‘StreamOpen’:
StreamDecoder.c:102:9: warning: ignoring return value of ‘avformat_write_header’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  102 |         avformat_write_header(pOutputContext, NULL);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [../Examples.mk:12: x86/obj/StreamDecoder.o] Error 1
make[1]: Leaving directory '/home/pi/Documents/git/orion-sdk/Examples/VideoPlayer'
make: *** [Makefile:2: build] Error 2
trilliumbuild commented 3 weeks ago

The top level make will try and build everything in the correct order if you have all the needed dependencies. It looks like having a working Protogen binary was the biggest hang up at first.

The errors you had with generating the Communications libraries will be resolved by checking out the 2.12.d version of Protogen. Check out https://github.com/trilliumeng/ProtoGen/releases/tag/2.12.d_trillium. The places you had to comment out lines in OrionPublicPacket.c/h are causes by newer incompatible Protogen versions.

You can add git checkout a0472b7 after you clone the repo. Otherwise I have made fork of Protogen that marks the correct release revision.

The VideoPlayer example can be picky about the version of ffmpeg/libavcodec being used. Can you help out with the version you are using to see if I can recommend a fix? I am running Ubuntu 22.04 on x64 and it all just works, but many users on various arm platforms with various different linux distros run into hiccups on the build. Usually it comes down to a working 2.12.d Protogen binary, and the various libav dependencies needed by the VideoPlayer example app.