0
0
Embedded Cprogramming~10 mins

Cross-compilation mental model in Embedded C - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the target architecture for cross-compilation.

Embedded C
#define TARGET_ARCH [1]
Drag options to blanks, or click blank then click option'
A"arm"
B"x86"
C"host"
D"native"
Attempts:
3 left
💡 Hint
Common Mistakes
Using "host" or "native" which refer to the current machine, not the target.
Choosing the same architecture as the host defeats cross-compilation.
2fill in blank
medium

Complete the command to invoke the cross-compiler for ARM architecture.

Embedded C
[1]-gcc main.c -o main
Drag options to blanks, or click blank then click option'
Ax86_64-linux-gnu
Bgcc
Carm-linux-gnueabi
Dclang
Attempts:
3 left
💡 Hint
Common Mistakes
Using "gcc" alone compiles for the host architecture, not cross-compiling.
Using "x86_64-linux-gnu" targets x86_64, not ARM.
3fill in blank
hard

Fix the error in the Makefile line to set the cross-compiler prefix.

Embedded C
CROSS_COMPILE = [1]
Drag options to blanks, or click blank then click option'
Aarm-linux-gnueabi
Barm-linux-gnueabi-gcc
Cgcc
Darm-linux-gnueabi-
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the dash causes command errors.
Using the full compiler name instead of the prefix.
4fill in blank
hard

Fill both blanks to create a dictionary mapping architectures to their cross-compiler prefixes.

Embedded C
const char* cross_prefixes[] = { [1], [2] };
Drag options to blanks, or click blank then click option'
A"arm-linux-gnueabi-"
B"mips-linux-gnu-"
C"gcc"
D"clang"
Attempts:
3 left
💡 Hint
Common Mistakes
Using compiler names instead of prefixes.
Omitting the dash at the end of prefixes.
5fill in blank
hard

Fill all three blanks to complete the cross-compilation command with architecture, source file, and output name.

Embedded C
[1]-gcc [2] -o [3]
Drag options to blanks, or click blank then click option'
Aarm-linux-gnueabi
Bmain.c
Cmain
Dx86_64-linux-gnu
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing host and target prefixes.
Swapping source and output file names.