Building for x86 and x64 Maybe a solution for this and some linking errors

Hi, i am new to this forum and solved the problem ‘building for x86 and x64’ with a modificated cuda building rule.

Cuda.rules.rar (2.46 KB)

At first you have to install both SDKs (x86 and x64) in a way as mentioned in some other topics and here. Because you need the x86 stuff (libs, includes…) from you CUDA and CUDA_SDK. I decided to introduce some new global vars denoting the x86 paths:


CUDA_SDK_PATH, CUDA_SDK_PATH_32 pointing to “[YOURPATH]\common” and “[YOURPATH]\common_x86” for x86

Like this:




CUDA_SDK_PATH=C:\ProgramData\NVIDIA Corporation\NVIDIA CUDA SDK\common
CUDA_SDK_PATH_32=C:\ProgramData\NVIDIA Corporation\NVIDIA CUDA SDK\common_x86

i just copied the x86 cuda staff and sdk/common and renamed as shown.

if you want to make x86 builds out of your x64 environment, take the new rules and edit your x86 build configuration like this:

Addional Includes

Addional Libs

or like you want to.

it works for me, i compiled all samples in x86 and x64. may be i can help you a bit.

maybe you have to copy the cudpp32d.dll, cudpp32.dll, cudart.dll to your x86 bins.

some of the samples take the cuda building rules, someothers dont do that, like “simpleTemplates”. just fix the commandline for building. almost the same thing. look carefully for the buildingrules of the *.cu files.

for everybody who has problems with some obj-files and errors like “fatal error LNK1112: module machine type ‘x64’ conflicts with target machine type ‘X86’”, look some lines above for the params of the nvcc. if you want to build for x86 the nvcc dont like things and paths with x64.

look into the new cuda rules, i modified

  • “Path to nvcc.exe”, take what you want, x86, x64 or alternate

  • “Additional Include Directories” at the bottom, the option “Andere” (other) activates the top line “Alternate Additional Include Directories” or choose x86, x64 for default includes from cuda and cuda_sdk.