![]() Save the C code below to a file called hello.cpp: int main() We now have all the pieces together, let’s compile our first C program. your home directory): rsync -rzLR -safe-links \ \ \ \ \ sysroot/ Bringing it all together ![]() Run the following command in your favourite directory (e.g. I found it more convenient to simply use rsync to sync the relevant directories directly to my Mac. This is however quite slow and requires to have the Rasbperry Pi online and running all the time while compiling. There are multiple ways to obtain them, like using remote file systems. ![]() In order to compile anything meaningful, we also need the libraries that come with our Raspberry Pi Linux distribution. In addition, we also install rsync from homebrew, which we need later: brew install arm-linux-gnueabihf-binutils llvm rsync Step 2: Sysroot In this step, we install clang as compiler and the GNU binutils compiled for the hard float GNU EABI, which is what most Linux distributions run. In order to compile for the Raspberry Pi, we need binutils to assemble and link binaries and a compiler that can produce code for the ARM CPU. This article expects that Xcode and homebrew are installed on your Mac and that your Raspberry Pi is running Linux and set up for login via ssh. Looking for something simpler? Then here you go: Prerequisites ![]() Now, there are powerful solutions like crosstool-ng and others, but they require a lot of setup and time. ![]() Cross compiling C/C from macOS to Raspberry Pi in 2 easy stepsĮvery now and then, I need to run some utility written in C on my Raspberry Pi. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |