Find the answer to your Linux question:
Results 1 to 5 of 5

Thread: cross-compiling

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    cross-compiling


    How can I compile a program on a platform (for example amd64) so that it will executable on another platform(for example x86)?
    Is it possible to tell Anjuta or Eclipse to do so?

  2. #2
    Linux Engineer Javasnob's Avatar
    Join Date
    Jul 2005
    Location
    Wisconsin
    Posts
    942
    You'll need to get a cross-compiler to do that, and I assume you can tell an IDE to use that compiler. I don't know where you can get cross-compiler binaries, but you can build one from source. Here's a tutorial for x86 -> Alpha; it should be a similar procedure for other arches.

    http://www.cse.unsw.edu.au/~cgray/cr...alpha-xcc.html
    Flies of a particular kind, i.e. time-flies, are fond of an arrow.

    Registered Linux User #408794

  3. #3
    Linux User
    Join Date
    Oct 2004
    Location
    /dev/random
    Posts
    404
    Quote Originally Posted by charmik24
    How can I compile a program on a platform (for example amd64) so that it will executable on another platform(for example x86)?
    Is it possible to tell Anjuta or Eclipse to do so?
    If it's specific to x86 architecture, then you don't need a cross compiler.
    You can instruct your x86-64 (AMD64) gcc to build a 32-bit executable by passing -m32 option. This is because IA32 (x86) is really a subset of x86-64 (aka x64).
    This can be enabled in ANY IDE in linux - almost all of them allow you to pass custom parameters to the compiler. However, I don't use these IDEs, so I don't know where you'd find the options to set the parameters

    PS: You need a cross-compiler only when you are compiling for a totally different architecture. For example, compiling for an ARM target on an x86 development host; or compiling for PPC linux target on an x86-linux development host or any such combination.
    The Unforgiven
    Registered Linux User #358564

  4. $spacer_open
    $spacer_close
  5. #4
    Thank you!
    Actually, I need it for Itanium not for x86. I use x86 just for a test.

    Yes, it works for x86 with the option -m32 from the console but I didn't find how can do this in IDE...
    and the other question...In the case of another arch..for ex. Itanium...Is it possible to configure my IDE for cross compilation?

  6. #5
    Linux User
    Join Date
    Oct 2004
    Location
    /dev/random
    Posts
    404
    -->
    Quote Originally Posted by charmik24
    Thank you!
    Actually, I need it for Itanium not for x86. I use x86 just for a test.

    Yes, it works for x86 with the option -m32 from the console but I didn't find how can do this in IDE...
    and the other question...In the case of another arch..for ex. Itanium...Is it possible to configure my IDE for cross compilation?
    Yes, for an itanium target, you'd need a cross-compiler as it's not part of the x86 family.
    As I said, almost all IDEs (including Anjuta and Eclipse) allow you to specify custom compiler settings. However, I don't have either of them installed on my machine at work, so I cannot check out where to find the options in the IDE

    Almost all IDEs work with Makefiles - they can export Makefiles for the projects.
    If you don't find an option to set the compiler, you can make the IDE export the Makefile and edit it manually to set the compiler (the CC variable in the Makefile). But, it should be fairly trivial to set the compiler options in the IDE.

    Edit:
    In Eclipse, you can set the compiler commands/options by navigating to Project -> Properties -> C/C++ Build -> Tool Settings tab in Configuration Settings frame.
    This is when you use "Managed Make ..." type of projects.
    The Unforgiven
    Registered Linux User #358564

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •