JCuda 0.4.1 compilation error

I am just trying to compile JCuda on my OpenSuse 12.1 64-bit system, CUDA 4.1. Unfortunately it is complaining about an invalid cast:

[ 27%] Built target CommonJNI
[ 36%] Building CXX object JCudaDriverJNI/CMakeFiles/JCudaDriver-linux-x86_64.dir/src/JCudaDriver.cpp.o
/opt/jcuda/JCuda-All-0.4.1-src/JCudaDriverJNI/src/JCudaDriver.cpp: In function ‘bool getOptionValue(JNIEnv*, jobject, CUjit_option, void*&)’:
/opt/jcuda/JCuda-All-0.4.1-src/JCudaDriverJNI/src/JCudaDriver.cpp:1378:28: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/opt/jcuda/JCuda-All-0.4.1-src/JCudaDriverJNI/src/JCudaDriver.cpp:1390:28: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/opt/jcuda/JCuda-All-0.4.1-src/JCudaDriverJNI/src/JCudaDriver.cpp: In function ‘jint Java_jcuda_driver_JCudaDriver_cuDeviceGetPCIBusIdNative(JNIEnv*, jclass, jobjectArray, jint, jobject)’:
/opt/jcuda/JCuda-All-0.4.1-src/JCudaDriverJNI/src/JCudaDriver.cpp:1999:66: error: cast from ‘void*’ to ‘CUdevice {aka int}’ loses precision [-fpermissive]
/opt/jcuda/JCuda-All-0.4.1-src/JCudaDriverJNI/src/JCudaDriver.cpp: In function ‘jint Java_jcuda_driver_JCudaDriver_cuIpcOpenMemHandleNative(JNIEnv*, jclass, jobject, jobject, jint)’:
/opt/jcuda/JCuda-All-0.4.1-src/JCudaDriverJNI/src/JCudaDriver.cpp:2123:31: warning: converting to non-pointer type ‘CUdeviceptr {aka long long unsigned int}’ from NULL [-Wconversion-null]
make[2]: *** [JCudaDriverJNI/CMakeFiles/JCudaDriver-linux-x86_64.dir/src/JCudaDriver.cpp.o] Error 1
make[1]: *** [JCudaDriverJNI/CMakeFiles/JCudaDriver-linux-x86_64.dir/all] Error 2
make: *** [all] Error 2

I am compiling with gcc version 4.3.4. and generated the make files by cmake -G “Unix Makefiles” -D CUDA_TOOLKIT_ROOT_DIR=/opt/cuda/ CMakeLists.txt

Am I missing a required configuration option?




Sorry this was reported earlier for 0.4.0RC2 ( http://forum.byte-welt.net/archive/index.php/t-3469.html ) and was fixed in most places for 0.4.0, but in 0.4.1 it has been re-introduced in one place (but it will be fixed in 0.4.2, I’m currently working on that).

The line 1999 should be changed from
CUdevice nativeDev = (CUdevice)getNativePointerValue(env, dev);
CUdevice nativeDev = (CUdevice)(intptr_t)getNativePointerValue(env, dev);