trouble with unresolved external symbol pgf90_str_copy_klen with PGI on Windows 10

I am trying to re-compile code that compiles fine on Windows 7, Windows SDK, Visual Studio 2017, PGI Community 19.4, plus the pre-compiled fftw3 libraries. This attempt is on Windows 10, Windows SDK, Visual Studio 2017, PGI Community 19.4. and the same pre-compiled fftw3 libraries.

Unfortunately on the new machine I’m getting unresolved external symbols:

pgf90 -Mcuda -o mustem_cpu_sngl *.obj -pgf90libs -Bdynamic “C:\Program Files\PGI\win64\2019\fftw3.3.5\libfftw3-3.lib” “C:\Program Files\PGI\win64\2019\fftw3.3.5\libfftw3f-3.lib” -I"C:\Program Files\PGI\win64\2019\fftw3.3.5"
s_qep_stem.obj : error LNK2001: unresolved external symbol pgf90_str_copy_klen
s_absorptive_tem.obj : error LNK2001: unresolved external symbol pgf90_str_copy_klen
m_lens.obj : error LNK2001: unresolved external symbol pgf90_str_copy_klen
m_absorption.obj : error LNK2001: unresolved external symbol pgf90_str_copy_klen
s_absorptive_stem.obj : error LNK2001: unresolved external symbol pgf90_str_cpy1
m_user_input.obj : error LNK2001: unresolved external symbol pgf90_str_cpy1
m_multislice.obj : error LNK2001: unresolved external symbol pgf90_str_malloc_klen
m_string.obj : error LNK2001: unresolved external symbol pgf90_str_malloc_klen
m_lens.obj : error LNK2001: unresolved external symbol pgf90_str_malloc_klen
m_multislice.obj : error LNK2001: unresolved external symbol pgf90_str_free
m_string.obj : error LNK2001: unresolved external symbol pgf90_str_free
m_lens.obj : error LNK2001: unresolved external symbol pgf90_str_free
m_lens.obj : error LNK2001: unresolved external symbol pgf90_strcmp_klen
m_multislice.obj : error LNK2001: unresolved external symbol pgf90_strcmp_klen
MS_utilities.obj : error LNK2019: unresolved external symbol pgf90_str_index_klen referenced in function setup_integration_measurements_
m_potential.obj : error LNK2001: unresolved external symbol pgf90_str_index_klen
mustem_cpu_sngl.exe : fatal error LNK1120: 6 unresolved externals
./mustem_cpu_sngl.exf: error STP001: cannot open file
make: *** [makefile:36: Hn0_tcmp] Error 2

I would be grateful for any pointers where to start looking.
cheers!

Answering my own post:

I used e.g. “dumpbin /linkermember libpgf90.lib | grep pgf90_str” on all *.lib in C:\Program Files\PGI\win64\19.4\lib to find out which library I needed to add to the linker and struck gold with:

libpgf90rtl.lib

After adding -lpgf90rtl the compile went through fine.

Now, not sure why I have to add this explicitly for this installation and not for the other?

Hi domuhe,

Now, not sure why I have to add this explicitly for this installation and not for the other?

Hmm, you shouldn’t need to add the PGI Fortran runtime library explicitly, it should be added by default. (You shouldn’t need -pgf90libs either)

Can you add the flags “-dryrun --keeplnk” can then post the resulting “pgi.lnk” file? This is the link line that will be given the the MS linker.

Thanks,
Mat

Thank you for responding, Mat.

Here is the pgi.lnk file:
C:\PROGRA~1\PGI/win64/19.4/lib\pgimainmx.obj
C:\PROGRA~1\PGI/win64/19.4/lib\f90main.obj
-incremental:no
-debug
-nologo
-merge:__nv_module_id=.data
-merge:.nvFatBinSegment=.data
“-libpath:C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/lib/x64”
“-libpath:C:/Program Files (x86)/Windows Kits/10/Lib/10.0.18362.0/ucrt/x64”
“-libpath:C:/Program Files (x86)/Windows Kits/10/Lib/10.0.18362.0/um/x64”
-libpath:C:\PROGRA~1\PGI/win64/19.4/lib
MS_utilities.obj
m_absorption.obj
m_crystallography.obj
m_electron.obj
m_lens.obj
m_multislice.obj
m_numerical_tools.obj
m_potential.obj
m_precision.obj
m_string.obj
m_tilt.obj
m_user_input.obj
mod_CUFFT_wrapper.obj
mod_global_variables.obj
mod_output.obj
muSTEM.obj
quadpack.obj
s_absorptive_stem.obj
s_absorptive_tem.obj
s_qep_stem.obj
s_qep_tem.obj
“C:\Program Files\PGI\win64\2019\fftw3.3.5\libfftw3-3.lib”
“C:\Program Files\PGI\win64\2019\fftw3.3.5\libfftw3f-3.lib”
-out:mustem_cpu_sngl.exe
-pdb:./mustem_cpu_sngl.pdb
-defaultlib:libcudafor101
-defaultlib:libcudafor
-defaultlib:libcudaforblas
C:\PROGRA~1\PGI/win64/19.4/lib\cuda_init_register_end.obj
-libpath:C:\PROGRA~1\PGI/win64/2019/cuda/10.1/lib/x64
-defaultlib:cudadevrt
-defaultlib:cudart
-defaultlib:libcudafor2
/DYNAMICBASE:NO
-defaultlib:pgmp
-defaultlib:pg
-defaultlib:pgf90rtl
-defaultlib:pgf90
-defaultlib:pgf90_rpm1
-defaultlib:pgf902
-defaultlib:pgf90rtl
-defaultlib:pgftnrtl
-defaultlib:pg
-defaultlib:pgf90rtl
-defaultlib:pgf90
-defaultlib:pgf90_rpm1
-defaultlib:pgf902
-defaultlib:pgf90rtl
-defaultlib:pgftnrtl
-nodefaultlib:libvcruntime
-nodefaultlib:libucrt
-nodefaultlib:libcmt
-defaultlib:msvcrt
-defaultlib:pgc
-defaultlib:libnspgc
-defaultlib:pgmath
-defaultlib:legacy_stdio_definitions
-defaultlib:oldnames

In the meantime I got it to compile fine without having to add -lpgf90rtl by dropping -Bdynamic. Which I now realise was a change I did make on the new system trying to link to the fftw3 dlls. I am new to compiling on Windows and still trying to find my way around shared, imported and static libraries.
Cheers!

Hi domuhe,

Did you also add -Bdynamic to the compilation flags as well as the link?

On Windows, the symbols to the DLL runtime libraries are different than the static runtime libraries, so -Bdynamic needs to be added to both the compile and link so the correct symbols are used.

My guess is that this is what’s happening given it works if you explicitly add the static runtime library.

Hope this helps,
Mat

Thanks!