<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Carl Hörberg</title>
    <description>The latest articles on DEV Community by Carl Hörberg (@carlhoerberg).</description>
    <link>https://dev.to/carlhoerberg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F479463%2Fe880173a-8c7b-4853-843f-8eae6f8c2e01.jpeg</url>
      <title>DEV Community: Carl Hörberg</title>
      <link>https://dev.to/carlhoerberg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/carlhoerberg"/>
    <language>en</language>
    <item>
      <title>Cross compile Crystal to aarch64</title>
      <dc:creator>Carl Hörberg</dc:creator>
      <pubDate>Thu, 01 Oct 2020 18:53:33 +0000</pubDate>
      <link>https://dev.to/carlhoerberg/cross-compile-crystal-to-aarch64-2g1</link>
      <guid>https://dev.to/carlhoerberg/cross-compile-crystal-to-aarch64-2g1</guid>
      <description>&lt;p&gt;Here's an example of how to cross compile a crystal app on a host machine and then transfering it to the target machine (in this case an Ubuntu aarch64/arm64) and compile the last bits there:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
#!/bin/bash -eu

srcfile=$1
target=$2

export CFLAGS="-fPIC"
buildcmd=$(crystal build --cross-compile --target=aarch64-unknown-linux-gnu --release $srcfile)

# Upload the object file to the aarch64 machine
scp "$(basename $srcfile .cr).o" "$target":.
rm "$(basename $srcfile .cr).o"

# SSH to the target machine
ssh "$target" &amp;lt;&amp;lt; EOF
# install dependencies
sudo apt-get install -y clang libssl-dev libpcre3-dev libgc-dev libevent-dev zlib1g-dev

# download and compile crystal's sigfault library
wget https://raw.githubusercontent.com/crystal-lang/crystal/master/src/ext/sigfault.c
cc -c -o sigfault.o sigfault.c
ar -rcs libcrystal.a sigfault.o
sudo mkdir -p /usr/share/crystal/src/ext
sudo cp libcrystal.a /usr/share/crystal/src/ext/

# compile the object file with the command crystal build --cross-compile gave us
$buildcmd
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>crystal</category>
    </item>
  </channel>
</rss>
