How to cross-compile 32-bit CUDA apps on a 64-bit platform?

Has anyone been able to cross-compile, link and run a 32-bit CUDA app on a 64-bit platform? According to tmurray’s July 21 post announcing the release of CUDA v2.3, “the 64-bit versions of the CUDA Toolkit now support compiling 32-bit applications,” so I imagine it must be possible. On Ubuntu 9.04 AMD64, I’m able to compile to 32-bit object code using g++ v4.3.3 and nvcc v2.3, but when trying to link with the 32-bit library in /usr/local/cuda/lib, using GNU ld v2.19.1 I, get the following errors:

skipping incompatible /usr/local/cuda/lib/libcudart.so when searching for -lcudart
cannot find -lcudart

My linker flags include -melf-i386. Do I need to install the 32-bit SDK and toolkit? If so, then what did tmurray mean in his post? Any help would be appreciated.

Thanks,

Allen

Did you add -m32 (during compiling and linking)?

Bingo (almost). Thanks. I was using that switch in my compile line, but not in my link line. Now, however, I find that the SDK’s cutil library is incompatible. So my next question is, do I need to rebuild cutil as a 32-bit library or do I need to install the 32-bit SDK? I’m imagining that at least one user of this forum has already skinned this cat. Currently, the linker returns these errors:

skipping incompatible NVIDIA_GPU_Computing_SDK/C/common/…/lib/libcutil.a when searching for -lcutil

cannot find -lcutil

The easiest solution is to simply not use cutil :) It will make many things so much easier.

If you really, absolutely, positively cannot avoid it, then you are going to have to modify the SDK makefiles to compile cutil with -m32 also.