<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pine64.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Theintern</id>
	<title>PINE64 - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pine64.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Theintern"/>
	<link rel="alternate" type="text/html" href="https://wiki.pine64.org/wiki/Special:Contributions/Theintern"/>
	<updated>2026-06-18T22:02:24Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Cross-compiling&amp;diff=10551</id>
		<title>Cross-compiling</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Cross-compiling&amp;diff=10551"/>
		<updated>2021-05-29T01:45:40Z</updated>

		<summary type="html">&lt;p&gt;Theintern: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Pinephone's triple for cross-compiling is aarch64-unknown-linux-gnu. &lt;br /&gt;
&lt;br /&gt;
= Rust =&lt;br /&gt;
In order to cross-compile Rust applications for the Pinephone, you need to have a gcc cross-compiler installed and the Rust dependencies, usually the std crate, cross compiled for the target system. A more extensive explanation can be found on https://github.com/japaric/rust-cross. This instruction is based on it's description.&lt;br /&gt;
&lt;br /&gt;
== Installing gcc cross-compiler ==&lt;br /&gt;
The cross-compiler might have a different name depending on the operating system. Further along this instruction the name for the gcc cross-compiler will be used. Replace all occurences of $gcc_name with the name on your distribution.&lt;br /&gt;
Under Arch Linux the cross-compilers name is aarch64-linux-gnu-gcc and it can be installed with:&lt;br /&gt;
  $ sudo pacman -S aarch64-linux-gnu-gcc&lt;br /&gt;
&lt;br /&gt;
Ubuntu:&lt;br /&gt;
  $ sudo apt install gcc-aarch64-linux-gnu&lt;br /&gt;
&lt;br /&gt;
Other distributions:&lt;br /&gt;
  Please add&lt;br /&gt;
&lt;br /&gt;
== Installing Rust dependencies ==&lt;br /&gt;
&lt;br /&gt;
The necessary dependencies can easily be installed with rustup:&lt;br /&gt;
  $ rustup target add aarch64-unknown-linux-gnu&lt;br /&gt;
OR it can be installed with multirust [Is this still accurate???]:&lt;br /&gt;
  $ multirust add-target nightly aarch64-unknown-linux-gnu&lt;br /&gt;
&lt;br /&gt;
== Compiling ==&lt;br /&gt;
&lt;br /&gt;
=== rustc === &lt;br /&gt;
&lt;br /&gt;
When using rustc just add the two flags --target=aarch64-unknown-linux-gnu and -C linker=$gcc_name. Under Arch, this would look like: &lt;br /&gt;
  $ rustc --target=aarch64-unknown-linux-gnu -C linker=aarch64-linux-gnu-gcc main.rs&lt;br /&gt;
&lt;br /&gt;
To test it, run the program on your Pinephone&lt;br /&gt;
&lt;br /&gt;
  $ scp main user@ipadress:/home/user/Downloads&lt;br /&gt;
  $ ssh user@ipadress /home/user/Downloads/main&lt;br /&gt;
  Hello, world!&lt;br /&gt;
&lt;br /&gt;
=== cargo === &lt;br /&gt;
To cross-compile a project with cargo, open the folder of the project in a terminal. Then create a new folder and a file for cargo.&lt;br /&gt;
  $ mkdir .cargo&lt;br /&gt;
  $ cat &amp;gt;.cargo/config &amp;lt;&amp;lt;EOF&lt;br /&gt;
  &amp;gt; [target.aarch64-unknown-linux-gnu]&lt;br /&gt;
  &amp;gt; linker = &amp;quot;$gcc_name&amp;quot;&lt;br /&gt;
  &amp;gt; EOF&lt;br /&gt;
Then you can compile it with&lt;br /&gt;
  $ cargo build --target=aarch64-unknown-linux-gnu&lt;br /&gt;
&lt;br /&gt;
To test it, copy the file on your Pinephone&lt;br /&gt;
  $ scp target/aarch64-unknown-linux-gnu/debug/main user@ipadress:/home/user/Downloads&lt;br /&gt;
Then you can execute it by&lt;br /&gt;
  $ ssh user@ipadress ./main -h&lt;br /&gt;
  Hello, world!&lt;br /&gt;
&lt;br /&gt;
== Possible errors ==&lt;br /&gt;
If you encounter an error saying&lt;br /&gt;
  Cross compilation detected. Use PKG_CONFIG_ALLOW_CROSS=1 to override&lt;br /&gt;
just add that variable in front of your command e.g.&lt;br /&gt;
  PKG_CONFIG_ALLOW_CROSS=1 cargo build --target=aarch64-unknown-linux-gnu&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone]]&lt;/div&gt;</summary>
		<author><name>Theintern</name></author>
	</entry>
</feed>