How to make a 64-bit C++ DLL?

Stan Huang 421 Reputation points
2021-02-04T00:20:32.487+00:00

I selected MachineX64 in the "Target Machine" of the property page of a C++ DLL project and then built it. I got the error "fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'". Why? In the "Platform" option, I chose 'Win32'.

My IDE is Visual Studio 2019 / Windows 10.

Developer technologies | C++
Developer technologies | Visual Studio | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 11,356 Reputation points Microsoft External Staff
    2021-02-04T03:05:42.3+00:00

    Hi,

    We couldn't use a .cmd file shipped with VS for setting the environment variables but instead use our own equivalent .cmd file. That file set the %PATH% variable for 32-bit cl.exe and that's exactly why C++ source was compiled with a 32-bit compiler. The soluton is to iether use the .cmd for x64 compilation shipped with VS or to craft a custom .cmd file setting %PATH% appropriately.

    And a more convenient way is that you can try to select "x64" instead of "win32".

    63777-241.png

    Best Regards,

    Jeanine


    If the response is helpful, please click "Accept Answer" and upvote it.

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

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.