Unresolved external symbol __environ

Hi all,

Let me preface by saying I’m not a Fortran guy. This is my first time even using PGI. I have some code that was developed by someone else and I’m trying to integrate it into a MFC C++ application. I’ve created a static library (compiled with pgf90) but I’m having an issue with linkage. I finally managed to track down almost all the libraries I was missing, but now I seem to be left with the following errors (VS2008):

error LNK2019: unresolved external symbol __environ referenced in function _pgf90_compiled
error LNK2001: unresolved external symbol __environ

I found only one similar problem on the forums here: PVF 2010 Linking C and Fortran

Much like the OP in that posting, I originally had a name mangling problem. I was able to correct that both using the -Miface=unix and by fixing it from the calling code. Like him, I also hit a lot of unresolved externals that were mostly cleaned up by linking in libpgsse1 and libpgsse2. I don’t really understand how to fix this issue, though.

Any help would be greatly appreciated.

The __environ is a global from the MS C run-time and is expected to be resolved
from some MS static library (could be libcmt.lib). It appears that whatever linking process
is being used it doesn’t include the static version of that library, but rather its corresponding DLL. You might try creating a DLL version of the pgf90 code which should cause the __environ extern to be imported from the appropriate MS DLL.