6

I have this simple program with its sources in a 'src' folder and the includes in the 'inc' folder. Normally i compile this with:

gcc -I../inc *.c

This leaves 'a.out' as program which works fine on that pc.

But how do i compile this for my BeagleBone Black (ARM)? With this i am thinking about:

gcc (some arguments to crosscompile for arm) -I../inc *.c
Embed101
  • 152
  • 2
  • 3
  • 12
  • 1
    Have you installed an ARM toolchain on your PC ? – Paul R Jan 14 '14 at 08:36
  • you don't `compile` it, actually you [cross-compile](http://en.wikipedia.org/wiki/Cross_compiler#GCC_and_cross_compilation) it. – Sourav Ghosh Jan 14 '14 at 08:42
  • Thank you for your question Paul. Yes i have. I am using the git archive and uboot for the kernel, so i am already using "make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm uImage". – Embed101 Jan 14 '14 at 08:43
  • 1
    what error you are getting? – Dipto Jan 14 '14 at 08:45
  • Good question Dipto, the point is that i am not actually shure how to cross-comile it for ARM and doing nothing does not give errors. I have tried "gcc CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm -I../inc *.c" which results in: "gcc: error: CROSS_COMPILE=arm-linux-gnueabi-: No such file or directory" and "gcc: error: ARCH=arm: No such file or directory". – Embed101 Jan 14 '14 at 08:49
  • 5
    You're getting confused between makefile options and gcc options - create a simple makefile for your project in the same style as your existing ARM makefile and then use `make CROSS_COMPILE=...` as you normally would. Alternatively look at the build commands generated when you make uImage and use the gcc switches from that. – Paul R Jan 14 '14 at 09:01
  • Sorry your right, bad mistake. But my kernel makefile is 1500 lines long. I don't intent diving into that. Are there no arguments i can give to gcc to make it crosscompile for arm? – Embed101 Jan 14 '14 at 09:11
  • Well, for a beaglebone black, you should be using an arm-linux-gnueabihf- toolchain. – unixsmurf Jan 14 '14 at 12:06
  • Don't be frightened to "dive in" - that is the best way to learn! – Paul R Jan 15 '14 at 10:45

1 Answers1

7

Since you say you can use make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm uImage you should have arm gnueabi toolchain available at your disposal. It should be then as easy as calling it like

arm-linux-gnueabi-gcc -I../inc *.c
auselen
  • 27,577
  • 7
  • 73
  • 114