How to cross-compile 64bit DLL with VS 2005 on 32b

2019-08-06 13:49发布

问题:

Using Visual Studio 2005, I wrote a simple DLL in C that uses the Windows API to send UDP datagrams and that is hooked into a third-party program. On a 64 bit machine, it does not work at all, as the third-party code was compiled for 64 bit in this case. So I need to ship two versions of the same DLL - one for 32 bit, one for 64 bit.

However, I did not manage to get Visual Studio (running on a 32 bit machine) to spit out a DLL that is not identical to the 32 bit version - it seems the 'machine' setting in the project properties is simply ignored. A colleague told me VS 2008 simply refuses to cross-compile in this scenario. Is this really not possible at all?

回答1:

Right click the project in the Solution Explorer then go Properties / Configuration Manager / Active Solution platform: <New...> / x64 / OK / Close. Then select x64 in Platform, OK, and you're good to go.