<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Yuzhou Cheng on Medium]]></title>
        <description><![CDATA[Stories by Yuzhou Cheng on Medium]]></description>
        <link>https://medium.com/@yuzhoucheng?source=rss-3695e66ef8d9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NtGYveUhNneG5LrRcKbWWw.jpeg</url>
            <title>Stories by Yuzhou Cheng on Medium</title>
            <link>https://medium.com/@yuzhoucheng?source=rss-3695e66ef8d9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 16:31:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yuzhoucheng/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Setup GCC 8.1 Cross Compiler Toolchain for Raspberry Pi 3 on macOS High Sierra]]></title>
            <link>https://medium.com/coinmonks/setup-gcc-8-1-cross-compiler-toolchain-for-raspberry-pi-3-on-macos-high-sierra-cb3fc8b6443e?source=rss-3695e66ef8d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb3fc8b6443e</guid>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[internet-of-things]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Yuzhou Cheng]]></dc:creator>
            <pubDate>Mon, 13 Aug 2018 03:30:14 GMT</pubDate>
            <atom:updated>2022-06-26T18:01:39.371Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IB-eaCjgcw50-erL" /><figcaption>Photo by <a href="https://unsplash.com/@mat_graphik?utm_source=medium&amp;utm_medium=referral">Jordane Mathieu</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>During this year’s <em>Amazon</em> Prime Day I found a nice lightning deal with <a href="https://www.amazon.com/Exploring-Raspberry-Pi-Interfacing-Embedded/dp/1119188687/ref=sr_1_fkmr2_1?ie=UTF8&amp;qid=1532847055&amp;sr=8-1-fkmr2&amp;keywords=explore+raspberry+pi+wiley">this book</a> written by Mr. Derek Molloy. I decide it’s a good time to start learning embedded development systematically. So here comes my journey.</p><p>With some hand-on experience with <em>AOSP</em> platform, I know that one will use <strong>gcc</strong> cross compiler on dev machine to generate binaries for target devices. It makes sense to compile something which requires more than ten gigabytes of hard disk space, no less than four gigabytes of RAM on a powerful computer. Also it is nice to build and hack in your favorite text editor/IDE on your most desired OS. As a result, having a cross compiler for <em>Raspberry Pi</em> which support latest <em>C/C++</em> standard sounds like a good start for my <em>Pi</em> adventure.</p><p>It is fantastic to live in the internet era. You don’t have to find an encyclopedia to start trying your idea. Simply type “<a href="https://www.google.com/search?newwindow=1&amp;rlz=1C5CHFA_enUS805US805&amp;ei=ymReW5vtIKqB0wLqzreoDw&amp;q=Raspberry+Pi+cross+compiler+macOS&amp;oq=Raspberry+Pi+cross+compiler+macOS&amp;gs_l=psy-ab.3..35i39k1j0i22i30k1l3.2749.11366.0.13239.11.9.2.0.0.0.305.995.7j1j0j1.9.0....0...1.1.64.psy-ab..0.4.229...0i30k1j0i8i30k1j0i13i30k1j0i8i13i30k1.0.pBZf0PNyZLc"><em>Raspberry Pi</em> cross compiler macOS</a>” into <em>Google</em> search box yields some <a href="https://www.jaredwolff.com/blog/cross-compiling-on-mac-osx-for-raspberry-pi/">promising result</a> (Thanks Mr. Wolff for such a nice blog post :). Everything about this article looks wonderful until I notice its publication date is September 2016. Back then the article is building the toolchain for “<em>armv7-rpi2-linux-gnueabihf</em>” which stands for <em>Raspberry Pi 2</em> (although it states that the guide supports <em>RPi3</em>). It supports only <strong>gcc</strong> 5.2 which has no <em>C++17/C++20</em>. Although there are some limitations, the guide is still a golden reference for my cross compiler experiment because it provides handy tips on how to play with <a href="https://crosstool-ng.github.io/"><strong>crosstool-ng</strong></a>, a wonderful project to configure and compile <strong>GNU</strong> toolchain for various platforms.</p><p>After a whole weekend of frustration with compiler/linker/tool errors, I am able to get a fully functional <strong>GNU</strong> toolchain on <em>macOS High Sierra</em> version 10.13.6 which generate binaries for platform “<em>armv8-rpi3-linux-gnueabihf</em>”. If you want to try out the binaries, the build artifacts are hosted with <a href="https://github.com/yc2986/armv8-rpi3-linux-gnueabihf-gcc-8.1.0-macos-high-sierra">my GitHub repo</a>. The project contains a <a href="https://github.com/yc2986/armv8-rpi3-linux-gnueabihf-gcc-8.1.0-macos-high-sierra/blob/master/.config">config file</a> for <strong>crosstool-ng</strong> and following <strong>GNU</strong> tools:</p><ul><li><strong><em>GNU make</em></strong><em> 4.2.1</em></li><li><strong><em>GNU Compiler Collection (gcc)</em></strong><em> 8.1.0</em></li><li><strong><em>GNU C Library (glibc)</em></strong><em> 2.27</em></li><li><strong><em>GNU Binutils</em></strong><em> 2.28</em></li><li><strong><em>GNU m4</em></strong><em> 1.4.18</em></li><li><strong><em>GNU Debugger (gdb)</em></strong><em> 8.1</em></li><li><strong><em>GNU Build system: autoconf </em></strong><em>2.69, </em><strong><em>automake</em></strong><em> 1.15, </em><strong><em>libtool</em></strong><em> 2.4.6</em></li></ul><p>Now I will show you how to get these tools from <strong>ct-ng</strong> compiler. In the first part I will list the correct dependencies and procedures required to make <strong>ct-ng</strong> works. In the second part I will share my experience with using <strong>crosstool-ng</strong>’s configuration menu interface. In the third part I will show you some bad errors I have come across and my work-arounds/solutions.</p><h4>Part 1: Successful Compilation Procedure</h4><p>Install <strong>Homebrew</strong> to get our required dependencies for <em>macOS</em></p><pre>/usr/bin/ruby -e &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&quot;</pre><p>Install <strong>crosstool-ng</strong></p><pre>brew install crosstool-ng</pre><p>Find the install directory for <strong>crosstool-ng</strong></p><pre>brew info crosstool-ng</pre><p>In my case the command returns the following result</p><pre>crosstool-ng: stable 1.23.0 (bottled)</pre><pre>Tool for building toolchains</pre><pre>http://crosstool-ng.org</pre><pre><em>/usr/local/Cellar/crosstool-ng/1.23.0_1</em> (1,294 files, 7.7MB) *</pre><pre>Poured from bottle on 2018-07-20 at 23:37:27</pre><pre>From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/crosstool-ng.rb</pre><p>We need to grant execution privilege to the crosstool-NG.sh script to resolve a potential workflow error.</p><pre>chmod +x <em>/usr/local/Cellar/crosstool-ng/1.23.0_1/lib/crosstool-ng-1.23.0/scripts/crosstool-NG.sh</em></pre><p>Some extra dependencies are required for <strong>libtool</strong> and <strong>gcc</strong> 8.1 compilation.</p><pre>brew install help2man bison</pre><p><strong>gcc</strong> 8.1 compile requires <strong>GNU bison</strong> to be higher version compared to the system default one. We need to link the brew version of <strong>bison</strong> since <em>macOS</em> will pick system default one from <em>/usr/bin/bison</em> rather than <strong>brew’s</strong> <em>/usr/local/bin/bison</em>.</p><pre>brew link --force bison</pre><pre># this linkage can be later reverted by running:<br>#   brew unlink bison</pre><pre># after the linking we should restart the console or run:<br>#   source <em>~/.bash_profile</em><br># to correctly apply the linkage. by running:<br>#   which bison<br># the console should return something other than <em>/usr/bin/bison</em></pre><p>Next we need to create a case-sensitive disk volume to house all the toolchain compiling artifacts. This can be achieved by simply opening <strong>Disk Utility</strong> and click the red circled button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nsTV-ACniskrEN7hMuLySA.png" /></figure><p>With <em>macOS High Sierra</em> we have <em>APFS</em> disk format which features better performance and file size optimization. As we are trying out the latest <strong>GNU</strong> toolchain, why not try it on the latest file system as well. I know new compiler + new file system format may lead me to quadruple headache, but WHY NOT :). In my case I name it <em>“xtool-build-env”</em> which uses “<em>APFS (case-sensitive)</em>” disk format. We will need 10 gigabytes of space for all intermediate object files and install files on an <em>APFS</em> volume. Use the size options button to do space pre-allocation work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z52b115DvVSK0YCLE8KzeA.png" /></figure><p>Now with the case sensitive volume ready at <em>/Volumes/xtool-build-env/</em>, it is time to start playing with <strong>ct-ng</strong> building system. The simplest way to configure the tool is to use the <a href="https://github.com/yc2986/armv8-rpi3-linux-gnueabihf-gcc-8.1.0-macos-high-sierra/blob/master/.config">config file</a> directly from my successful build. Place this config at</p><pre><em>/Volumes/xtool-build-env/.config</em></pre><p>Then open the it and edit these path to match your system setup. You can change the volume name or use any folder under the case sensitive <em>APFS</em> volume as you like. In my case:</p><pre>CT_WORK_DIR=&quot;<em>/Volumes/xtool-build-env/.build</em>&quot;<br>CT_PREFIX_DIR=&quot;<em>/Volumes/xtool-build-env/${CT_TARGET}</em>&quot;<br>CT_LOCAL_PATCH_DIR=&quot;<em>/Volumes/xtool-build-env/packages</em>&quot;</pre><p>Note that in above settings I have set <strong>CT_LOCAL_PATCH_DIR</strong> together with local patch over bundled patch rule within the config. This requires us to copy everything under <a href="https://github.com/crosstool-ng/crosstool-ng/tree/master/packages"><strong>crosstool-ng</strong>’s packages folder</a> and place it under <em>/Volumes/xtool-build-env/packages/</em>.</p><p>Let’s check <em>macOS</em>’s user limits by command:</p><pre>ulimit -n</pre><p>If the system limits the resource to only 256, try increase it to at least 1024 with:</p><pre>ulimit -n 1024<br># re-run &quot;ulimit -n&quot; to make sure this step succeeded</pre><p>For convenience, I have enabled the option <strong>CT_DEBUG_CT_SAVE_STEPS</strong> in the config file. This ensures us whenever one build step fails, we can fix the issue and restart right at the failing point. Since the toolchain build is a time consuming process, enable save step will save us a lot of time.</p><p>At this point we have finished all the prerequisites for compiling <strong>gcc</strong> 8.1.0. However, some change for <strong>gcc</strong> 8.1.0 source code is needed to resolve one of the compiler errors.</p><p>Let’s start by listing the available build step using the follow command:</p><pre>ct-ng list-steps</pre><p>In my local environment <strong>ct-ng</strong> returns following build steps</p><pre>Available build steps, in order:<br>- companion_tools_for_build<br>- companion_libs_for_build<br>- binutils_for_build<br>- companion_tools_for_host<br>- companion_libs_for_host<br>- binutils_for_host<br>- cc_core_pass_1<br>- kernel_headers<br>- libc_start_files<br>- cc_core_pass_2<br>- libc<br>- cc_for_build<br>- cc_for_host<br>- libc_post_cc<br>- companion_libs_for_target<br>- binutils_for_target<br>- debug<br>- test_suite<br>- finish<br>Use &quot;&lt;step&gt;&quot; as action to execute only that step.<br>Use &quot;+&lt;step&gt;&quot; as action to execute up to that step.<br>Use &quot;&lt;step&gt;+&quot; as action to execute from that step onward.</pre><p>For example if the build fails at step <strong>cc_for_build</strong>, which means the last success step saved is step <strong>libc</strong>, we can trouble shoot and fix the issue, then restart the build with command:</p><pre>ct-ng libc+</pre><p>The plus sign at tail means executing following actions from <strong>libc</strong> step onward.</p><p>Now we will download the source code, configure the build tool dependency and make some change into <strong>gcc</strong> 8.1.0 source code. Run this:</p><pre>ct-ng +companion_tools_for_build</pre><p>After the first step correctly finished, we will have all source codes downloaded, decompressed and patched using the git patch file from <em>/Volumes/xtool-build-env/packages/</em> folder. Now we should edit this file:</p><pre>vi <em>/Volumes/xtool-build-env/.build/src/gcc-8.1.0/libatomic/configure</em></pre><p>Search and change the following line</p><pre>XCFLAGS=&quot;$XCFLAGS -Wall -Werror&quot;</pre><p>To</p><pre>XCFLAGS=&quot;$XCFLAGS -Wall&quot;</pre><p>This is a workaround to get pass the warning error generated while compiling <strong>gcc libatomic.</strong> The warning message is about -mcpu conflicting with -march compiler flag. This is not a good solution, any suggestion for a proper fix is appreciated.</p><p>With everything set let’s kick off our build. Below command will resume our build from the last saving point with our edited source code change.</p><pre>ct-ng companion_tools_for_build+</pre><p>It’s time to grab a cup of tea and wait for our shiny compiler to be ready in 40 minutes.</p><p>If everything goes well, the toolchain should be available at <em>/Volumes/xtool-build-env/armv8-rpi3-linux-gnueabihf/</em>. Let’s test out the latest <em>C++17/C++20</em> feature with a <a href="https://github.com/yc2986/CMakeRPiExample">sample project</a>. The project require <strong>CMake</strong> for configuration, so get the dependency with:</p><pre>brew install cmake</pre><p>Then clone into the git repo, run the following command to build with the cross-toolchain:</p><pre>cd build<br>cmake .. &amp;&amp; make</pre><p>The test application will be available at <em>CMakeRPiExample/build/executable/executable</em>. Copy this application to your RPi3 device with following rsync command. I have given my Raspberry Pi the hostname of pi0, so my command will be</p><pre>rsync -rtzh <em>CMakeRPiExample/build/executable/executable</em> pi@pi0:/home/pi</pre><p>Then ssh into your device and execute the application from home directory. It will create 10 <em>std::thread</em> objects within which several std::<em>any</em> object is initialized and used to store integer variables. A <em>C++20</em> style <em>__VA_OPT__</em> macro is used to test <em>C++2a</em> capabilities. If everything compiles fine, the application should return something similar to this</p><pre>thread 0 finished<br>thread 8 finished<br>thread 1 finished<br>thread 2 finished<br>thread 3 finished<br>thread 4 finished<br>thread 5 finished<br>thread 6 finished<br>thread 7 finished<br>thread 9 finished<br>double params foo: static c1 optional c2 param<br>single param foo: static c1</pre><p>We have successfully test out <em>C++11/C++17/C++20</em> feature with a tiny sample project :) The compiler is ready for use in our exciting future projects!</p><h4>Part 2: Play With crosstool-ng Configuration File</h4><p>In part 1 I have provided a fine tuned config file which enables building latest <strong>gcc</strong>, setting patch application rules, and using step by step builds. In this section I will explain how to play with <strong>crosstool-ng</strong>’s <em>menuconfig</em> and how to tinker with the config file to adopt latest <em>gcc/gdb</em> and other toolsets.</p><p>First I will start with initializing a config file for target platform. Available target can be found under the <a href="https://github.com/crosstool-ng/crosstool-ng/tree/master/samples">sample directory</a> from <strong>crosstool-ng</strong>’s Git repo. In our case, with target of <em>RPi3,</em> let’s run below init command within directory of <em>/Volumes/xtool-build-env/</em></p><pre>ct-ng armv8-rpi3-linux-gnueabihf</pre><p>Then launch the <em>menuconfig</em> for <strong>ct-ng</strong>. Run following command to start the interface:</p><pre>ct-ng menuconfig</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xeslgvBVtg63E9zKshef3w.png" /><figcaption><strong>ct-ng</strong> menuconfig interface</figcaption></figure><p>Basically, <em>path/patch/debug</em> related options will reside in <em>Paths and misc options</em> submenu. <em>C-library</em> is for configuration <strong>glibc</strong> related parameters. <em>C compiler</em> menu provide options for <strong>gcc</strong> compilers. <em>Debug facilities</em> let you choose <strong>gdb</strong> and memory trace tool you would like to have for <em>RPi3</em>.</p><p>For path configuration, I have used these menu items:</p><pre>Paths and misc options<br>-- (<em>/Volumes/xtool-build-env/src</em>) Local tarballs directory<br>-- (<em>/Volumes/xtool-build-env/.build</em>) Working directory<br>-- (<em>/Volumes/xtool-build-env/${CT_TARGET}</em>) Prefix directory</pre><p>For patch application:</p><pre>Paths and misc options<br>-- Patches origin (Local only, bundled if no local)<br>-- (<em>/Volumes/xtool-build-env/packages</em>)   Local patch directory</pre><p>For debug options:</p><pre>Paths and misc options<br>[*] Debug crosstool-NG<br>[*]   Save intermediate steps<br>[*]     gzip saved states</pre><p>For <strong>glibc</strong> and <strong>gcc</strong> with the current <em>menuconfig</em> under <strong>crosstool-ng</strong> 1.23.0 we can only have the following options:</p><pre>C-library<br>-- glibc version (2.25)</pre><pre>C compiler<br>-- gcc version (6.3.0)</pre><p>This means the most up-to-date version of <strong>glibc</strong> and <strong>gcc</strong> we can get from official <strong>ct-ng</strong> config interface is <strong>glibc</strong><em> 2.25</em> and <strong>gcc</strong><em> 6.3.0</em>. Not too old but not up-to-date either. Same situation for other tools like <strong>gdb</strong> and etc etc…</p><p>With official supported <strong>ct-ng</strong> configuration tool, if you do everything correctly, you should be able to get the toolchain around <strong>gcc</strong> 6.3.0 with partial <em>C++17</em> support.</p><p>To get a more “modern” version of compiler, it’s time to open the config file and mess up with it ourselves :). After edit and save for <em>menuconfig</em>, you should be able to find a .config file under <em>/Volumes/xtool-build-env/</em>. Open that config with your favorite editor, identify these options:</p><pre>CT_CC_GCC_VERSION=&quot;6.3.0&quot;<br>CT_LIBC_VERSION=&quot;2.25&quot;<br>CT_GDB_VERSION=&quot;7.12.1&quot;</pre><p>These are the version strings which will be used by <strong>ct-ng</strong> to pull source tarball from <em>sourceforge</em>. We can substitute these with the latest available versions. One good place to find correct version of toolchains with patch support is <a href="https://github.com/crosstool-ng/crosstool-ng/tree/master/packages"><strong>crosstool-ng</strong>’s patch package</a> directory. For example open this <a href="https://github.com/crosstool-ng/crosstool-ng/tree/master/packages/gcc"><strong>gcc</strong> patch</a> folder, you will see <strong>crosstool-ng</strong> has officially brought their patch support for up to version 8.1.0. In this case we can safely change our <strong>CT_CC_GCC_VERSION</strong> to “8.1.0” since this means <strong>crosstool-ng</strong> is actively working on supporting <strong>gcc</strong> 8.1.0. Same rule apply for all other toolchain components.</p><p>You can always experiment with different combinations as long as there is patch available. Even for ones without patch support we can certainly bring it in as a local resource and apply our own patches to make it <strong>ct-ng</strong> compatible! I am not familiar with this area. Nice to see someone post such an article to play with customized toolchains.</p><p>After all the hack and tinkering around config file, we can test out with command</p><pre>ct-ng build</pre><p>With the debug step saving enabled, it is simple to parse the build log and fix the issue then resume from the failure point.</p><h4>Part 3: Trouble Shooting</h4><p>In this section, I will document the error which may block the compilation process and provide the resolutions. There are lots of <strong>ct-ng</strong> related trouble shooting articles which can be found via <em>Google</em>. I will only focus on the problems raised by compiling <strong>gcc</strong> 8.1.0 here.</p><p>My local environment parameters:</p><ul><li><strong>crosstool-ng</strong> path: <em>/usr/local/Cellar/crosstool-ng/1.23.0_1/</em></li><li>Case sensitive <em>APFS</em> volume root: <em>/Volumes/xtool-build-env/</em></li><li>Config file path: <em>/Volumes/xtool-build-env/.config</em></li><li><strong>crosstool-ng</strong> build log path: <em>/Volumes/xtool-build-env/build.log</em></li><li>Toolchain source tarball path: <em>/Volumes/xtool-build-env/.build/tarballs/</em></li><li>Toolchain source path: <em>/Volumes/xtool-build-env/.build/src/</em></li><li>Toolchain installation path: <em>/Volumes/xtool-build-env/armv8-rpi3-linux-gnueabihf</em></li></ul><p>List of problems and resolutions:</p><ol><li>Permission denied error after running <strong>ct-ng</strong> build command</li></ol><blockquote><strong>Error message:</strong></blockquote><blockquote>/bin/bash: /usr/local/Cellar/crosstool-ng/1.23.0_1/lib/crosstool-ng-1.23.0/scripts/crosstool-NG.sh: Permission denied</blockquote><blockquote><strong>Solution:</strong></blockquote><blockquote>Grant executing privilege to crosstool-NG.sh script:</blockquote><pre>chmod +x /usr/local/Cellar/crosstool-ng/1.23.0_1/lib/crosstool-ng-1.23.0/scripts/crosstool-NG.sh</pre><p>2. <strong>crosstool-ng</strong> build fails during compile of <strong>libtool</strong></p><blockquote><strong>Error message:</strong></blockquote><blockquote>[EXTRA] Building libtool<br>[ERROR] make[3]: *** [Makefile:2328: /Volumes/Unix/ct-ng/.build/src/libtool-2.4.6/doc/libtool.1] Error 127</blockquote><blockquote><strong>Build log error message:</strong></blockquote><blockquote>[ALL ] WARNING: ‘help2man’ is missing on your system.<br>[ALL ] You should only need it if you modified a dependency of a man page.<br>[ALL ] You may want to install the GNU Help2man package:<br>[ALL ] &lt;<a href="http://www.gnu.org/software/help2man/">http://www.gnu.org/software/help2man/</a>&gt;</blockquote><blockquote><strong>Solution:</strong></blockquote><blockquote>Install help2man with Homebrew:</blockquote><pre>brew install help2man</pre><p>3. <strong>crosstool-ng</strong> build fails at step <em>Installing pass-1 core C gcc compiler</em></p><blockquote><strong>Error message:</strong></blockquote><blockquote>[INFO ] Installing pass-1 core C gcc compiler<br>[EXTRA] Configuring core C gcc compiler<br>[EXTRA] Building gcc<br>[ERROR] clang: error: linker command failed with exit code 1 (use -v to see invocation)</blockquote><blockquote><strong>Build log error message:</strong></blockquote><blockquote>[ALL ] ld: framework not found ../libiberty/pic/libiberty.a</blockquote><blockquote><strong>Solution:</strong></blockquote><blockquote>Make sure all patches are downloaded and applied to the source code at the start of build. Specifically patches are from crosstool-ng’s offical Github repo <a href="https://github.com/crosstool-ng/crosstool-ng/tree/master/packages">package directory</a>. These patches should be put in a local folder which matches <strong>CT_LOCAL_PATCH_DIR</strong> option inside the config file.</blockquote><blockquote>Note that if build fails at this step, we should use the resolution above and restart the build from beginning by:</blockquote><pre>ct-ng build</pre><p>4. <strong>crosstool-ng</strong> build fails at step <em>Building for multilib</em></p><blockquote><strong>Error message:</strong></blockquote><blockquote>[ERROR] &gt;&gt; Build failed in step ‘Building for multilib 1/1</blockquote><blockquote><strong>Build log error message:</strong></blockquote><blockquote>[CFG ] checking version of bison… 2.3, bad</blockquote><blockquote><strong>Solution:</strong></blockquote><blockquote>Install bison with Homebrew and force link to use the brew version:</blockquote><pre>brew install bison<br>brew link --force bison</pre><pre># this linkage can be later reverted by running:<br>#   brew unlink bison</pre><pre># after the linking we should restart the console or run:<br>#   source <em>~/.bash_profile</em><br># to correctly apply the linkage. by running:<br>#   which bison<br># the console should return something other than <em>/usr/bin/bison</em></pre><p>5. <strong>crosstool-ng</strong> Build fails at step <em>Installing final gcc compiler</em></p><blockquote><strong>Error message:</strong></blockquote><blockquote>[ERROR] &gt;&gt; Build failed in step ‘Installing final gcc compiler’</blockquote><blockquote><strong>Build log error message:</strong></blockquote><blockquote>[ERROR] cc1: error: switch -mcpu=cortex-a53 conflicts with -march=armv7-a switch [-Werror]</blockquote><blockquote><strong>Solution:</strong></blockquote><blockquote>This is a brute force solution by disable Werror from the configure file. If anyone can come up with a good solution to resolve the error please comment below, thanks!</blockquote><blockquote>To disable Werror, edit <em>/Volumes/xtool-build-env/.build/src/gcc-8.1.0/libatomic/configure</em> file. Substitute line</blockquote><pre>XCFLAGS=&quot;$XCFLAGS -Wall -Werror&quot;</pre><blockquote>to</blockquote><pre>XCFLAGS=&quot;$XCFLAGS -Wall&quot;</pre><p>6. Other errors</p><blockquote><strong>Solution:</strong></blockquote><blockquote>Google the error message directly or ignore it if it doesn’t break your build :)</blockquote><h4><strong>Ending</strong></h4><p>Now we have the cross compiler for RPi3, infinity possibilities are in our hands to make the small device a powerful tool for home automation, IoT, embedded computer vision etc…</p><p>As for me, I will happily go on with my book reading using my self built cross compiler. If interesting stories happen in my embedded Linux learning, I will keep you posted :)</p><h4>Reference</h4><p>[1] <a href="https://www.jaredwolff.com/blog/cross-compiling-on-mac-osx-for-raspberry-pi/">Cross Compiling on Mac OSX for Raspberry Pi</a> by <a href="https://www.jaredwolff.com/">Jared Wolff</a></p><p>[2] <a href="https://github.com/crosstool-ng/crosstool-ng"><strong>crosstool-ng</strong> Github repo</a></p><p>[3] <a href="http://crosstool-ng.github.io/docs/"><strong>crosstool-ng</strong> official documentation</a></p><blockquote>Join Coinmonks<a href="https://t.me/coincodecap"> Telegram Channel</a> and<a href="https://www.youtube.com/c/coinmonks/videos"> Youtube Channel</a> get daily <a href="http://coincodecap.com/">Crypto News</a></blockquote><h4>Also, Read</h4><ul><li><a href="https://medium.com/coinmonks/top-10-crypto-copy-trading-platforms-for-beginners-d0c37c7d698c">Copy Trading</a> | <a href="https://medium.com/coinmonks/crypto-tax-software-ed4b4810e338">Crypto Tax Software</a></li><li><a href="https://coincodecap.com/grid-trading">Grid Trading</a> | <a href="https://medium.com/coinmonks/the-best-cryptocurrency-hardware-wallets-of-2020-e28b1c124069">Crypto Hardware Wallet</a></li><li><a href="http://Top 4 Telegram Channels for Crypto Traders">Crypto Telegram Signals</a> | <a href="https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a">Crypto Trading Bot</a></li><li><a href="https://medium.com/coinmonks/binance-trading-bots-d0d57bb62c4c">Binance Trading Bots</a> |<a href="https://medium.com/coinmonks/okex-review-6b369304110f"> OKEx Review</a> |<a href="https://coincodecap.com/atani-review"> Atani Review</a></li><li><a href="https://medium.com/coinmonks/best-crypto-signals-telegram-5785cdbc4b2b">Best Crypto Trading Signals Telegram</a> |<a href="https://medium.com/coinmonks/moonxbt-review-6e4ab26d037"> MoonXBT Review</a></li><li><a href="https://coincodecap.com/buy-shiba-bitbns">How to buy Shiba(SHIB) Coin on Bitbns?</a> |<a href="https://coincodecap.com/buy-floki-inu-token"> Buy Floki</a></li><li><a href="https://coincodecap.com/coinflex-review">CoinFLEX Review</a> |<a href="https://coincodecap.com/aex-exchange-review"> AEX Exchange Review</a> |<a href="https://coincodecap.com/upbit-review"> UPbit Review</a></li><li><a href="https://coincodecap.com/best-cryptocurrency-blogs">10 Best Cryptocurrency Blogs</a> |<a href="https://coincodecap.com/youhodler-review"> YouHodler Review</a></li><li><a href="https://medium.com/coinmonks/crypto-exchange-dd2f9d6f3769">Best Crypto Exchange</a> | <a href="https://medium.com/coinmonks/bitcoin-exchange-in-india-7f1fe79715c9">Best Crypto Exchange in India</a></li><li><a href="https://medium.com/coinmonks/best-crypto-apis-for-developers-5efe3a597a9f">Best Crypto APIs</a> for Developers</li><li>Best <a href="https://medium.com/coinmonks/top-5-crypto-lending-platforms-in-2020-that-you-need-to-know-a1b675cec3fa">Crypto Lending Platform</a></li><li><a href="https://medium.com/coinmonks/free-crypto-signals-48b25e61a8da">Free Crypto Signals</a> | <a href="https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a">Crypto Trading Bots</a></li><li>An ultimate guide to <a href="https://medium.com/coinmonks/leveraged-token-3f5257808b22">Leveraged Token</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb3fc8b6443e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/setup-gcc-8-1-cross-compiler-toolchain-for-raspberry-pi-3-on-macos-high-sierra-cb3fc8b6443e">Setup GCC 8.1 Cross Compiler Toolchain for Raspberry Pi 3 on macOS High Sierra</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>