nvcc generating invalid error compiling JNI code

$ nvcc --version
nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176

The error is:

MyFile.cu(231): error: expression must have pointer type

The relevant code:

JNIEXPORT jboolean JNICALL Java_MyFile_convergeMatrixCuda (
JNIEnv *env, jclass clazz, jfloatArray fxnMatrixJ, jfloatArray mulMatrixJ, jfloatArray addMatrixJ,
jfloatArray resultsJ, jint numRowsJ, jint numColsJ, jint maxIterations, jfloat epsilonJ)
{
int numRows = (int) numRowsJ;
int numCols = (int) numColsJ;
int maxIter = (int) maxIterations;
float epsilon = (float) epsilonJ;
float *fxnMatrixH = (*env)->GetFloatArrayElements (env, fxnMatrixJ, NULL);

GetFloatArrayElements returns a float*. Replacing “(*env)->GetFloatArrayElements” with “(env)->GetFloatArrayElements” gets these errors:

MyFile.cu(231): error: argument of type “JNIEnv *” is incompatible with parameter of type “jfloatArray”

MyFile.cu(231): error: argument of type “jfloatArray” is incompatible with parameter of type “jboolean *”

MyFile.cu(231): error: too many arguments in function call

nvcc does work correctly when compiling non-JNI code

  1. Is it possible to provide all the code?
  2. Is it possible to upgrade to CUDA 10.2?
  3. Are you running on Linux/Windows/Mac?
  4. Are you trying to compile Java (Java Native Interface)?
  5. What build commands are you using?

These links might be of interest.

https://devtalk.nvidia.com/default/topic/414688/cuda-library-embedding-in-java-with-jni/
https://stackoverflow.com/questions/22866901/using-java-with-nvidia-gpus-cuda

The correct call is:
float *fxnMatrixH = env->GetFloatArrayElements (fxnMatrixJ, NULL);

IOW, one less level of dereference for env, AND remove env from the parameter list