Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2012 32bit compilation on 64bit system

I have recently wanted to build a dll plugin for a program. Problem is, the program is 32bit, but by default my Visual Studio 2012's C++ compiler creates 64bit binaries, and I don't know how to change it - I've found the Configuration Manager and tried to create a new platform but there's only x64 as an option.

Am I trying to set the target architecture in the wrong place or what? Is there an update or something I can download so that I can create my dll? Is there a compiler switch that I can set somewhere?

Hope this screen helps:

enter image description here

like image 296
joker.neophyte Avatar asked Nov 15 '25 21:11

joker.neophyte


2 Answers

To build for 32 bit architecture, you have to open project properties window, and then Linker options.

Set the value of Target Machine option to MachineX86.

like image 53
Mani Ghasemnia Hamedani Avatar answered Nov 18 '25 11:11

Mani Ghasemnia Hamedani


  • Check the Build Configuration (Build -> Configuration Manager), and ensure that your DLL project for 32-bit is selected.
  • Check the linker settings, and ensure correct path is given.
  • After build, check that .DLL is produced at correct path, and is 32-bit (should be!).

You can use Dependency Walker to check if DLL is 32-bit or 64-bit. You also didn't mention if /clr option is used with this DLL or not. With /CLR, managed binary is produced. Though this option wouldn't alter bit-ness of the binary, you can just check if this is the case.

like image 35
Ajay Avatar answered Nov 18 '25 11:11

Ajay