question

StanHuang-4827 avatar image
0 Votes"
StanHuang-4827 asked S41L0R-8709 commented

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

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.

c++vs-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Instead of editing the existing “Win32” platform, I think that you should go to Configuration Manager dialog and create a new “x64” platform for your projects and solution, if it does not exist yet. Then select it as Active platform and rebuild the projects.

0 Votes 0 ·

1 Answer

JeanineZhang-MSFT avatar image
0 Votes"
JeanineZhang-MSFT answered S41L0R-8709 commented

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.



241.png (2.0 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.