2

I am trying to compile a library in linux with gcc. I want the lib to run on a different platform.

With configure, we normally use build and host. However, this library has no configure option. So I am writing my own code to compile lib using GCC. How I can specify the target machine as an option with GCC?

user1388142
  • 581
  • 2
  • 11
  • 26

1 Answers1

4

Unless the target is already possible with the current GCC (e.g. like the -m32 option of GCC on x86-64 Linux) you cannot compile your code with your usual GCC.

You have to either download and install a GCC cross-compiler or compile (as a cross-compiler using the --target= option for ./configure) GCC from its source code.

Every GCC installation has one single (main) target.

BTW, some Linux distributions are packaging some GCC cross-compilers. On Debian I have gcc-arm-none-eabi (targeted for ARM) and gcc-msp430 (targeted for MSP430)

osvein
  • 625
  • 2
  • 10
  • 31
Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547