Linking Problems (Unresolved PGI symbols)

I get the following error message when trying to compile my PGI OpenACC program on Windows (v 16.7) as a DLL:

pgcc5dI0ecMTp8qpDg.obj : error LNK2019: unresolved external symbol __pgi_uacc_dataexitstart referenced in function frea
pgcc5dI0ecMTp8qpDg.obj : error LNK2019: unresolved external symbol __pgi_uacc_dataoffb2 referenced in function frea
pgcc5dI0ecMTp8qpDg.obj : error LNK2019: unresolved external symbol __pgi_uacc_dataexitdone referenced in function frea
pgcc5dI0ecMTp8qpDg.obj : error LNK2019: unresolved external symbol __pgi_uacc_dataenterstart referenced in function aa
pgcc5dI0ecMTp8qpDg.obj : error LNK2019: unresolved external symbol __pgi_uacc_dataonb referenced in function aa
pgcc5dI0ecMTp8qpDg.obj : error LNK2019: unresolved external symbol __pgi_uacc_dataenterdone referenced in function aa
pgcc5dI0ecMTp8qpDg.obj : error LNK2019: unresolved external symbol __pgi_uacc_upstart referenced in function cpad
pgcc5dI0ecMTp8qpDg.obj : error LNK2019: unresolved external symbol __pgi_uacc_datadowna referenced in function cpad
pgcc5dI0ecMTp8qpDg.obj : error LNK2019: unresolved external symbol __pgi_uacc_updone referenced in function cpad
identity01_pgi.dll : fatal error LNK1120: 9 unresolved externals

Obviously something is wrong, but I don’t think it’s the code. It seems to me that there are some missing libraries that cannot be found, but I am not sure how this is happening? I am going by the user’s guide on how to make a DLL by doing ‘pgcc -acc -Bdynamic -o file.obj file.c’ and then doing ‘pgcc -acc -Mmakedll -o file.dll file.obj’ but something is going wrong. What am I missing?

Just to clarify, I can confirm that the example of building a DLL on Windows from the User’s Guide does in fact work, but I will note that the example given in the guide does not use OpenACC.

Hi Aaron,

Try adding the following libraries:

PGI$ pgcc -acc -Mmakedll -o file.dll file.obj  -ta=tesla:nordc -laccapi -laccg
-laccn -laccg2

Note that you’ll need to compile and link with the “-ta=tesla:nordc” flag. RDC requires the code to be linked with the CUDA device linker (nvlink) which can’t be done when putting the code in a DLL. Without RDC, you won’t be able to call device routines (#pragma acc routine) or use global data (#pragma acc declare create).

  • Mat

Thanks for the hint. This is working now. Is there any reason these libraries are not included automatically when creating DLLs like this?

It should. I added an RFE: TPR#22971 - Add OpenACC runtime when building a DLL