Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4712

C/C++ • Re: Trying to cross-complie for Raspberry Pi Zero 2 w

$
0
0
OK. I figured it out. Apparently the compiler expects a specific version for libcstdc++ to be supported. When I downloaded the g++ aarch64 C++ cross compiler I picked g++-13-aarch64-linux-gnu package as it was flagged as the recommended package in the Ubuntu repositiry according to the Synaptic Package Manager. Apparently, package 13 wants a libstdc++ to be VERSION 32. But Raspberry Pi only distributes a libstdc++ of max version 30 supported.

So, I looked at the Synaptic Package manager and there is a g++-12-aarch64-linux-gnu package available. So, I loaded the g++-12-aarch64-linux-gnu package. It loaded a bunch of other support packages, cpp-12, gcc-12, etc. I was worried it would copy over the aarch64-linux-gnu-g++ but it didn't. It was smart enough to avoid package crashing. I checked using

Code:

$ dpkg-query -L g++-12-aarch64-linux-gnu/./usr/usr/bin/usr/bin/aarch64-linux-gnu-g++-12/usr/lib/usr/lib/gcc-cross/usr/lib/gcc-cross/aarch64-linux-gnu/usr/lib/gcc-cross/aarch64-linux-gnu/12/usr/lib/gcc-cross/aarch64-linux-gnu/12/cc1plus/usr/lib/gcc-cross/aarch64-linux-gnu/12/g++-mapper-server/usr/share/usr/share/doc/usr/share/doc/gcc-12-aarch64-linux-gnu-base/usr/share/doc/gcc-12-aarch64-linux-gnu-base/C++/usr/share/doc/gcc-12-aarch64-linux-gnu-base/C++/README.C++/usr/share/doc/gcc-12-aarch64-linux-gnu-base/C++/changelog.gz/usr/share/lintian/usr/share/lintian/overrides/usr/share/lintian/overrides/g++-12-aarch64-linux-gnu/usr/share/man/usr/share/man/man1/usr/share/man/man1/aarch64-linux-gnu-g++-12.1.gz/usr/share/doc/g++-12-aarch64-linux-gnu
Note that it added a"-12" in appropriate places to allow packages 12 and 13 to exist simultaneously.

So, then I did a build using the "-12" version

Code:

$ aarch64-linux-gnu-g++-12 --sysroot=/opt/sdk/rpi_zero_2_w main.cpp scp a.out sws.local:b.outchrisk@sws.local's password: a.out                                        
Then on the target machine (hostname sws.local) I ran the b.out executable (the one I cross compiled on the build host)

Code:

$ ./b.outStarting77.41F 25.23C49.70%^C
So, for user level applications I want to cross compile I need to use the "-12" versions of the commands. I'll probably keep using the "-13" version for the kernel since that seems to be working fine.

I guess it makes sense that it worked when compiling it on the RPI Zero 2 w. On the target the g++ compiler is version 12.

Code:

 $ g++ --versiong++ (Debian 12.2.0-14) 12.2.0Copyright (C) 2022 Free Software Foundation, Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The "-12" version of the cross compiler is also version 12

Code:

$ aarch64-linux-gnu-g++-12 --versionaarch64-linux-gnu-g++-12 (Ubuntu 12.3.0-17ubuntu1) 12.3.0Copyright (C) 2022 Free Software Foundation, Inc.This is free software; see the source for copying conditions.  There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Thanks
Chris

Statistics: Posted by chriskot870 — Wed Sep 04, 2024 1:52 am



Viewing all articles
Browse latest Browse all 4712

Trending Articles