ARM Cross-Compiling in C

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
VoidElite
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 54
Joined: Sun Apr 24, 2011 5:25 am
Current Project: Lunar Sanity, 2D engine for PC.
Favorite Gaming Platforms: Playstation
Programming Language of Choice: C
Location: England

ARM Cross-Compiling in C

Post by VoidElite »

Hey guys. Trying to get a simple Hello World application to compile on:
*i386
*ppc
*armv6

I'm using this Makefile:

Code: Select all

I386_GCC=/Developer/usr/llvm-gcc-4.2/bin/i686-apple-darwin10-llvm-gcc-4.2
PPC_GCC=/Developer/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-gcc-4.2
ARM_GCC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/arm-apple-darwin10-llvm-gcc-4.2
APP=iOS_Test

Main: Main.o
	$(I386_GCC) -o bin//$(APP) obj/i386/*.c
	$(PPC_GCC) -o bin/ppc/$(APP) obj/ppc/*.c
	$(ARM_GCC) -o bin/armv6/$(APP) obj/armv6/*.c
	
Main.o:
	$(I386_GCC) -o obj/i386/$(APP).o src/*.c
	$(PPC_GCC) -o obj/ppc/$(APP).o src/*.c
	$(ARM_GCC) -o obj/armv6/$(APP).o src/*.c
When compiling Main.c into Main.o and then linking Main.o into iOS_Test for the ARM architecture it fails with these errors:
Last login: Sat Jun 11 18:58:24 on ttys000
Marc-A-Reeds-MacBook-Pro:~ MarcAReed$ cd iOS_Test
Marc-A-Reeds-MacBook-Pro:iOS_Test MarcAReed$ make
/Developer/usr/llvm-gcc-4.2/bin/i686-apple-darwin10-llvm-gcc-4.2 -o obj/i386/iOS_Test.o src/*.c
/Developer/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-gcc-4.2 -o obj/ppc/iOS_Test.o src/*.c
/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/arm-apple-darwin10-llvm-gcc-4.2 -o obj/armv6/iOS_Test.o src/*.c
In file included from /usr/include/sys/_types.h:33,
from /usr/include/_types.h:27,
from /usr/include/stdio.h:64,
from src/Main.c:1:
/usr/include/machine/_types.h:36:24: error: arm/_types.h: No such file or directory
In file included from /usr/include/_types.h:27,
from /usr/include/stdio.h:64,
from src/Main.c:1:
/usr/include/sys/_types.h:94: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_blkcnt_t’
/usr/include/sys/_types.h:95: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_blksize_t’
/usr/include/sys/_types.h:96: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_dev_t’
/usr/include/sys/_types.h:99: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_gid_t’
/usr/include/sys/_types.h:100: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_id_t’
/usr/include/sys/_types.h:101: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_ino64_t’
/usr/include/sys/_types.h:103: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_ino_t’
/usr/include/sys/_types.h:107: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_mach_port_name_t’
/usr/include/sys/_types.h:108: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_mach_port_t’
/usr/include/sys/_types.h:109: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_mode_t’
/usr/include/sys/_types.h:110: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_off_t’
/usr/include/sys/_types.h:111: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_pid_t’
/usr/include/sys/_types.h:131: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_sigset_t’
/usr/include/sys/_types.h:132: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_suseconds_t’
/usr/include/sys/_types.h:133: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_uid_t’
/usr/include/sys/_types.h:134: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_useconds_t’
In file included from src/Main.c:1:
/usr/include/stdio.h:70: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘va_list’
/usr/include/stdio.h:75: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘off_t’
/usr/include/stdio.h:80: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘size_t’
/usr/include/stdio.h:87: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fpos_t’
/usr/include/stdio.h:145: error: expected specifier-qualifier-list before ‘fpos_t’
/usr/include/stdio.h:255: error: expected declaration specifiers or ‘...’ before ‘fpos_t’
/usr/include/stdio.h:265: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fread’
/usr/include/stdio.h:270: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
/usr/include/stdio.h:272: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fwrite’
/usr/include/stdio.h:290: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:296: error: expected declaration specifiers or ‘...’ before ‘va_list’
/usr/include/stdio.h:297: error: expected declaration specifiers or ‘...’ before ‘va_list’
/usr/include/stdio.h:298: error: expected declaration specifiers or ‘...’ before ‘va_list’
/usr/include/stdio.h:301: error: expected declaration specifiers or ‘...’ before ‘va_list’
/usr/include/stdio.h:322: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:331: error: expected declaration specifiers or ‘...’ before ‘off_t’
/usr/include/stdio.h:332: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ftello’
/usr/include/stdio.h:353: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:355: error: expected declaration specifiers or ‘...’ before ‘va_list’
/usr/include/stdio.h:356: error: expected declaration specifiers or ‘...’ before ‘va_list’
/usr/include/stdio.h:357: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:357: error: expected declaration specifiers or ‘...’ before ‘va_list’
/usr/include/stdio.h:358: error: expected declaration specifiers or ‘...’ before ‘va_list’
/usr/include/stdio.h:372: error: expected declaration specifiers or ‘...’ before ‘fpos_t’
/usr/include/stdio.h:385: error: expected declaration specifiers or ‘...’ before ‘va_list’
In file included from /usr/include/stdio.h:443,
from src/Main.c:1:
/usr/include/secure/_stdio.h:42: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/secure/_stdio.h:49: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/secure/_stdio.h:49: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/secure/_stdio.h:56: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/secure/_stdio.h:57: error: expected declaration specifiers or ‘...’ before ‘va_list’
/usr/include/secure/_stdio.h:63: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/secure/_stdio.h:63: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/secure/_stdio.h:64: error: expected declaration specifiers or ‘...’ before ‘va_list’
make: *** [Main.o] Error 1
Marc-A-Reeds-MacBook-Pro:iOS_Test MarcAReed$ 1
Seems to be compatibility issues between stdio.h and the ARM architecture.

Any ideas how to fix this?

EDIT: I think stdio.h can't be compiled for the ARM architecture if so how do I over come this obstacle?
I love 16-bit Assembly language programming. I'm currently having an affair with C++. I'm working on a 2D Game Engine called Lunar Sanity for PC and soon DC. I own three games consoles: Dreamcast, Xbox 360 and Atari Flashback. I'm on a Mac and soon a PC. I love Windows XP as it works great(can run 16-bit GUIs). I've been programming for 3 years(since I was 11).

I settling into my hybrid(procedural&object orientated) life. It's all good so far. :)
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: ARM Cross-Compiling in C

Post by Falco Girgis »

Nah, you can definitely use stdio.h on ARM... and pretty much any architecture supports it.

It's pretty apparent that GCC just can't find the particular includes for ARM types which are required by stdio.h. With a bit of researching, these flags may help:

Code: Select all

-arch armv7 and -isysroot 
Although I must be honest, all of that iPhone shit is really DESIGNED to be compiled through XCode. You'll run into all sorts of obscure issues like this with a makefile.
User avatar
VoidElite
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 54
Joined: Sun Apr 24, 2011 5:25 am
Current Project: Lunar Sanity, 2D engine for PC.
Favorite Gaming Platforms: Playstation
Programming Language of Choice: C
Location: England

Re: ARM Cross-Compiling in C

Post by VoidElite »

GyroVorbis wrote:Nah, you can definitely use stdio.h on ARM... and pretty much any architecture supports it.

It's pretty apparent that GCC just can't find the particular includes for ARM types which are required by stdio.h. With a bit of researching, these flags may help:

Code: Select all

-arch armv7 and -isysroot 
Although I must be honest, all of that iPhone shit is really DESIGNED to be compiled through XCode. You'll run into all sorts of obscure issues like this with a makefile.
I think that should be '-arch armv6' because that's what the compiler was for. But due to the fact that I'm directly invoking the ARM GCC compiler instead of GCC it does not allow me to use the arch flag. Maybe I should just use GCC? But when I use raw GCC it finds the PPC shit and i386 shit but not the ARM compiler.

Should I invoke the GCC(NA(COMPILER MOANS WHEN I PASS -ARCH ARMV6 TO GCC)) compiler or the ARM GCC(/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/arm-apple-darwin10-llvm-gcc-4.2) compiler?

EDIT: This is what happens when I try to run GCC with 'arch -armv6' or 'armv7':
gcc-4.2: error trying to exec '/usr/bin/arm-apple-darwin10-gcc-4.2.1': execvp: No such file or directory
Also when I add '-isysroot' it complains about it missing a parameter.
EDIT2: I've found some information mentioning something about passing '$SDKROOT' or something to the '-isysroot' but I believe this was Xcode-side. I have reason to believe I need to find the value of this 'SDKROOT' which I believe now is known as 'SDK_DIR' in later versions of the iOS SDK.

NOTE: I've got the iOS SDK installed ext.
I love 16-bit Assembly language programming. I'm currently having an affair with C++. I'm working on a 2D Game Engine called Lunar Sanity for PC and soon DC. I own three games consoles: Dreamcast, Xbox 360 and Atari Flashback. I'm on a Mac and soon a PC. I love Windows XP as it works great(can run 16-bit GUIs). I've been programming for 3 years(since I was 11).

I settling into my hybrid(procedural&object orientated) life. It's all good so far. :)
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: ARM Cross-Compiling in C

Post by avansc »

Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
VoidElite
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 54
Joined: Sun Apr 24, 2011 5:25 am
Current Project: Lunar Sanity, 2D engine for PC.
Favorite Gaming Platforms: Playstation
Programming Language of Choice: C
Location: England

Re: ARM Cross-Compiling in C

Post by VoidElite »

Would I be right in thinking that I should use '-I' and '-L' to explicitly define the location of the headers and libs for the Darwin ARM GCC compiler?
I love 16-bit Assembly language programming. I'm currently having an affair with C++. I'm working on a 2D Game Engine called Lunar Sanity for PC and soon DC. I own three games consoles: Dreamcast, Xbox 360 and Atari Flashback. I'm on a Mac and soon a PC. I love Windows XP as it works great(can run 16-bit GUIs). I've been programming for 3 years(since I was 11).

I settling into my hybrid(procedural&object orientated) life. It's all good so far. :)
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: ARM Cross-Compiling in C

Post by LeonBlade »

VoidElite wrote:Would I be right in thinking that I should use '-I' and '-L' to explicitly define the location of the headers and libs for the Darwin ARM GCC compiler?
-l is for library name, -L is for library path. (sorry for this post I was a bit tired when I posted it and didn't really read I meant that -l and -L isn't for header files)
Last edited by LeonBlade on Mon Jun 13, 2011 2:03 pm, edited 1 time in total.
There's no place like ~/
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: ARM Cross-Compiling in C

Post by Falco Girgis »

VoidElite wrote:Would I be right in thinking that I should use '-I' and '-L' to explicitly define the location of the headers and libs for the Darwin ARM GCC compiler?
Yes, most likely. If I were you, I would look to see what arguments XCode is giving GCC when compiling an iOS project through XCode.
User avatar
VoidElite
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 54
Joined: Sun Apr 24, 2011 5:25 am
Current Project: Lunar Sanity, 2D engine for PC.
Favorite Gaming Platforms: Playstation
Programming Language of Choice: C
Location: England

Re: ARM Cross-Compiling in C

Post by VoidElite »

GyroVorbis wrote:
VoidElite wrote:Would I be right in thinking that I should use '-I' and '-L' to explicitly define the location of the headers and libs for the Darwin ARM GCC compiler?
Yes, most likely. If I were you, I would look to see what arguments XCode is giving GCC when compiling an iOS project through XCode.
Well you see, that's the hard part. I barely know how to use Xcode for anything but basic things. Also Apple are no help as they keep details like that retained most of the time. :3
I love 16-bit Assembly language programming. I'm currently having an affair with C++. I'm working on a 2D Game Engine called Lunar Sanity for PC and soon DC. I own three games consoles: Dreamcast, Xbox 360 and Atari Flashback. I'm on a Mac and soon a PC. I love Windows XP as it works great(can run 16-bit GUIs). I've been programming for 3 years(since I was 11).

I settling into my hybrid(procedural&object orientated) life. It's all good so far. :)
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: ARM Cross-Compiling in C

Post by avansc »

VoidElite wrote:
GyroVorbis wrote:
VoidElite wrote:Would I be right in thinking that I should use '-I' and '-L' to explicitly define the location of the headers and libs for the Darwin ARM GCC compiler?
Yes, most likely. If I were you, I would look to see what arguments XCode is giving GCC when compiling an iOS project through XCode.
Well you see, that's the hard part. I barely know how to use Xcode for anything but basic things. Also Apple are no help as they keep details like that retained most of the time. :3
Gyro is right, and xcode does not "hide" this.
here is just an example of one of my own projects.

Image
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: ARM Cross-Compiling in C

Post by Falco Girgis »

VoidElite wrote:
GyroVorbis wrote:
VoidElite wrote:Would I be right in thinking that I should use '-I' and '-L' to explicitly define the location of the headers and libs for the Darwin ARM GCC compiler?
Yes, most likely. If I were you, I would look to see what arguments XCode is giving GCC when compiling an iOS project through XCode.
Well you see, that's the hard part. I barely know how to use Xcode for anything but basic things. Also Apple are no help as they keep details like that retained most of the time. :3
Actually, no. Avansc is right. Usually everything I hate about XCode is that it keeps NOTHING hidden from you.
Post Reply