Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8759015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:41:40+00:00 2026-06-13T14:41:40+00:00

I am trying to compile a very simple program using the -m32 flag. If

  • 0

I am trying to compile a very simple program using the -m32 flag.

If I try to do this using gcc -m32 it works just fine(I have the needed libs)

Yet, when I add this flag to my flags in a makefile, I get a weird error
This is the makefile that I have

CC=gcc
CFLAGS=-m32 -O1 -W -Wall -pedantic -std=c99

all: main.o 
    $(CC) -o main main.o 
    rm main.o 

clean: 
    rm main

The error that I receive is the following

gcc -o main main.o
/usr/bin/ld: i386 architecture of input file `main.o' is incompatible with i386:x86-64 output
collect2: ld returned 1 exit status
make: *** [all] Error 1

Can someone please tell me what does this mean? and how can I fix it?

As for the code, the code does NOTHING except printing ‘hello world’

I am using GCC 4.4.3 under Linux 2.6.35 64-bits

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:41:42+00:00Added an answer on June 13, 2026 at 2:41 pm

    Your mistake is that you don’t pass -m32 to the linker.

    You actually need to change your Makefile to look like this:

    CC=gcc
    CFLAGS=-m32 -O1 -W -Wall -pedantic -std=c99
    LDFLAGS = -m32
    
    all: main.o 
        $(CC) $(LDFLAGS) -o main main.o 
        rm main.o 
    
    clean: 
        rm main
    

    An even better approach would be the following Makefile:

    CC=gcc
    CFLAGS=-m32 -O1 -W -Wall -pedantic -std=c99
    LDFLAGS=-m32
    
    .INTERMEDIATE: main.o
    
    all: main
    
    main: main.o
    
    clean: 
        -rm main
    

    In the later you just say that main depends on main.o and GNU Make will invoke the linker with the LDFLAGS as arguments for you as it invokes the compiler with the CFLAGS as arguments for the main.o

    “The targets which .INTERMEDIATE depends on are treated as intermediate files. See section Chains of Implicit Rules. .INTERMEDIATE with no dependencies marks all file targets mentioned in the makefile as intermediate.” Special Built-in Target Names

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just trying to compile and run a very simple test program, but
I’m trying to compile a very simple Hello world OpenGL 3.3 program using FreeGLUT.
I am trying to compile a very simple C program. Installed MinGW using auto
I have a very simple example program that I am trying to compile, but
I am trying to get a very simple program to compile while using functions
I am trying out a very simple cpp program on osx just to get
I am trying to cross-compile a very simple program for Android that worked with
I'm trying to compile a very simple program that makes a connection to a
I am trying to build a very simple C++ program using the Maven NAR
I'm trying to compile a very simple program in Java 1.6 on Ubuntu Jaunty,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.