Trying to use nmake to compile an executable for the x86 environment from the command line

nope no 65 Reputation points
2023-06-07T17:55:57.6133333+00:00

LIBCMT.lib(chkstk.obj) : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'

is the error in question

here's the command line and flags:

CC = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\SDK\ScopeCppSDK\vc15\VC\bin\CL.exe"
CFLAGS = -D_WIN32 -DDEBUG /c /nologo /GR /GX /W3 /Gy /MT /Zi

I'm trying to compile it for x86. I've also tried using vssalsx86.bat to change the environment, but that doesn't work. Neither does using the x86 native tools compiler command line.

Any ideas?

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,544 questions
{count} votes

Accepted answer
  1. Minxin Yu 10,121 Reputation points Microsoft Vendor
    2023-06-09T02:27:34.77+00:00

    Hi,

    I downloaded the repos and modified your makefile , then built successfully.

    1. Please try downloading the latest Visual Studio and installing the C++ workload.
      User's image

    The path "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/LIB.EXE" and "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/CL.exe" do not need to be specified.

    1. Use MKLIB = lib and CC = cl
    2. option 'GX' has been deprecated. Use 'EHsc' instead of 'GX'.

    4.Open Visual Studio x86 Command Prompt in Win->Apps
    User's image

    5.Create lib folder and build.

    User's image

    enter image description here

    enter image description here

    enter image description here

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. nope no 65 Reputation points
    2023-06-09T16:39:15.2666667+00:00

    Did you also have to change the .o extensions to .obj?

    otherwise it seems to say "cannot open filename.o"

    0 comments No comments