Cross Compilation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • singhPrabhat
    New Member
    • Aug 2008
    • 12

    Cross Compilation

    Hi Everyone,

    I want to make executable for 32-bit machine by using Makefile on 64-bit machine.
    Currently I am having gcc4.2.1 on my box.


    Thanks.
  • arnaudk
    Contributor
    • Sep 2007
    • 425

    #2
    Look at reference for gcc compiler flags, paying particular attention to the section "Target Options".

    Comment

    • singhPrabhat
      New Member
      • Aug 2008
      • 12

      #3
      make executable on 32-bit from 64-bit machine

      Originally posted by arnaudk
      Look at reference for gcc compiler flags, paying particular attention to the section "Target Options".
      -b machine how can I find the value for machine?

      how can I configure cross compiler? As in the link given by you tell about
      For example, if a cross-compiler was configured with `configure arm-elf', meaning to compile for an arm processor with elf binaries, then you would specify -b arm-elf to run that cross compiler

      I want to make executable for 32-bit machine.

      can you guide me on how to write gcc command in Makefile for cross compilation.

      Thanks for your response.

      Comment

      • arnaudk
        Contributor
        • Sep 2007
        • 425

        #4
        You'll need to install a version of gcc for each target machine type to use it as a cross compiler, see installation instructions. There are some exceptions. For example, if your gcc is installed on a 64-bit intel machine, and you simply want to compile for a 32-bit intel machine, then you can use intel hardware options such as -m32. The same applies to other hardware platforms. Have a good look through the manual and use google.

        Comment

        • singhPrabhat
          New Member
          • Aug 2008
          • 12

          #5
          Originally posted by arnaudk
          You'll need to install a version of gcc for each target machine type to use it as a cross compiler, see installation instructions. There are some exceptions. For example, if your gcc is installed on a 64-bit intel machine, and you simply want to compile for a 32-bit intel machine, then you can use intel hardware options such as -m32. The same applies to other hardware platforms. Have a good look through the manual and use google.
          my target machine is having gcc3.2.2 and my local machine is gcc4.2.1. Do I need to install gcc3.2.2 on my local box?

          how can I find option (-b) for the target machine?

          CCWebBrowser: $(OBJs)

          $(GCC) -m32 -o CCWebBrowser.li nux $(OBJs) $(LSSLLIBs) $(LICULIBs)

          If I give target as above then it creates executable but for 64-bit.

          Comment

          • arnaudk
            Contributor
            • Sep 2007
            • 425

            #6
            The compiler version on your target machine doesn't matter because you're not going to use it when you run the program there.

            You need to specify -m32 for the dependencies as well. You can do this easily by changing the line which looks something like GCC = g++ into something like GCC = g++ -m32. Make sure you do a full rebuild. Note also that you'll need to link in 32bit versions of any libraries you use as well...

            I think it may be easier just to configure a version of gcc tailored to targeted platform as per the installation instructions. Then to compile your code for your target machine change the line to GCC = <target-platform>-g++

            Comment

            Working...