unresolved _cudafor_ and _iso_c_binding_

Now I’m working on a project with the example code “http://www.pgroup.com/lit/samples/matmul.CUF”, and step by step as :

  1. Open PVF
  2. Create a new project, selecting “empty project”.
  3. In the solution explorer, add matmul.CUF to the source files.
  4. Right-mouse click on the project properties, select “Fortran->Language”, and then change the “CUDA Fortran” drop-down to “yes”.
  5. Select the menu option “Build->Build Solution” to build the executable.
  6. Finally, select the menu option “Debug->Start Without Debugging” to run the executable.
    It compiles well, but encounters the “unresolved external symbol cudafor and iso_c_binding” errors when linking.

Is there anything to do with the project properties?? (pgi visual fortran 2008 (with vs shell) )


Causes have been found---- The “calling convention” is set to “unix”. When set to “default”, it works.
Now I have another question: In my visual Fortran project, some Fourtran subroutine has to call some static library from the cuda c files. As the regular fortran subroutine calling c functions, the “calling convention” should be set to “unix”. Now there is an conflict.
How should I handle this situation?

Hi Benstone,

I’ve sent a report a report to our engineers about adding support for the UNIX with the CUDA Fortran modules (TPR#16932). Hopefully, we can have this added soon.

As for calling a C library from Fortran without using -Munix, you may need to use the “!$DEC” directives to specify the C function’s calling convention. See page 162 of the PGI User’s Guide. I believe the CUDA C libraries are built using the “STDCALL” convention instead of the default “CDECL”, though I’m not positive.

Note that 64-bit Windows does not have this issue(it uses a single calling convention), so if you’re able, you might try 64-bits as well.

Hope this helps,