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

  • SEARCH
  • Home
  • 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 4569578
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:14:21+00:00 2026-05-21T19:14:21+00:00

My question is similar to Targeting both 32bit and 64bit with Visual Studio in

  • 0

My question is similar to Targeting both 32bit and 64bit with Visual Studio in same solution/project.

However, I need to accomplish this in a GNUmakefile.

For instance, if i wanted to cross compile 32 and 64 bit applications via gcc, I can use the -m32 & -m64 flags during compilation and linking. This method is different for visual studio because I have to run vcvarsall.bat x86 to compile for 32 bit and vcvarsall.bat x64 for 64 bit to setup my environment for compilation.

all: foo.exe foo64.exe

foo.exe: obj32/foo.o
    link.exe /MACHINE:X86 $(OTHER_FLAGS) /out:$@ $^

foo64.exe: obj64/foo.o
    link.exe /MACHINE:X64 $(OTHER_FLAGS) /out:$@ $^

obj32/foo.o: foo.c
    cl.exe $(CFLAGS) $(INCLUDE_DIRS) /Fo$@ /c $<

obj64/foo.o: foo.c
    cl.exe $(CFLAGS) $(INCLUDE_DIRS) /Fo$@ /c $<

The above sample would not work because you need to rerun the vcvarsall.bat environment script in between compilation of 32 and 64 bit. If I try to compile the above sample makefile when after running vcvarsall.bat x86, I would get this error when trying to link the 64 bit executable:

 fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

Is there a way we can accomplish building both 32 and 64 bit applications with one invocation of make?

  • 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-05-21T19:14:22+00:00Added an answer on May 21, 2026 at 7:14 pm

    You don’t have to use vcvars. Those are convenience scripts for building in one platform environment or the other. By explicitly invoking the proper commands and passing them the appropriate options you can compile both without having to invoke two different batch files.

    Here is one way to write your “foo” program example as a GNU makefile:

    BIN32 = $(VS100COMNTOOLS)..\..\vc\bin
    BIN64 = $(VS100COMNTOOLS)..\..\vc\bin\amd64
    LIB32 =
    LIB64 = \
        /libpath:"$(VS100COMNTOOLS)..\..\vc\lib\amd64" \
        /libpath:"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\x64"
    
    all: foo.exe foo64.exe
    
    foo.exe: obj32/foo.obj
        "$(BIN32)/link.exe" /MACHINE:X86 $(OTHER_FLAGS) $(LIB32) /out:$@ $^
    
    foo64.exe: obj64/foo.obj
        "$(BIN64)/link.exe" /MACHINE:X64 $(OTHER_FLAGS) $(LIB64) /out:$@ $^
    
    obj32/foo.obj: foo.c
        "$(BIN32)/cl.exe" $(CFLAGS) $(INCLUDE_DIRS) /Fo$@ /c $<
    
    obj64/foo.obj: foo.c
        "$(BIN64)/cl.exe" $(CFLAGS) $(INCLUDE_DIRS) /Fo$@ /c $<
    

    This still assumes vcvarsall.bat x86 was run beforehand but with more work even that can be eliminated.

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

Sidebar

Related Questions

I posted a question similar to this earlier, however, after thinking about it and
This is a question similar to a question here . I wonder is there
I have asked a question similar to this in the past but this is
The question is similar to one . However, it differs in putting all subdirectories
This question is similar to this one How do I add options to a
This question is similar to Getting Emacs fill-paragraph to play nice with javadoc-like comments
I have a question similar to This one . But I want to implement
I posted another question similar. This is my old code as some ppl say
There is a similar question targeting the Java VM but I haven't found a
Similar to this previous question , I am having a problem with text alignment

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.