VS2010 and PGI Fortran mixed?

Is it possible to debug fortran code in dll if calling program is written in Visual C++?

I’ve tried do this: set main program as startup executable in dll’s project settings, then run debug instance… to “freezes” for dozen seconds , then OS messages “pgdebug.exe has been stopped” (I translate from my language)

I didn’t found anything relevant to this so far.

host OS: Windows 7 x64 with service packs
PGI Fortran 12.10 for VS2010
java 1.7.21 x64

iwhen I open PGI shell link and type pgdbg I ger error that required component isn’t found: jpgdbg.jar

edit:
apparently on none of machines we have 12.10 installed on no jpgdbg.jar present… provided what I scaped from other forum post it should be in installation directory - at least for linux… but installer never adds it

Hi Swiftkill,

Is it possible to debug fortran code in dll if calling program is written in Visual C++?

You can debug the DLL if you are using the PVF debug engine rather than the VC debugger. The debug engine choice is made by whatever the StartUp project is; so you’d set the PVF DLL project as the StartUp project in the Solution Explorer. Then, in that project’s Debugging | Command property, put the full path to the exe built by the VC project.

We do have an example project (Found at C:\Program Files (x86)\Microsoft Visual Studio 11.0\PGI Visual Fortran\Samples\dlls\pvf_dll) which is set-up this way if you need an example.

when I open PGI shell link and type pgdbg I ger error that required component isn’t found: jpgdbg.jar

PVF does not ship the stand-alone debugger hence why the component isn’t found. You’ll need to install the PGI Workstation to use the PGDBG GUI.

Though, you can still use the command line PGDBG by adding the “-text” flag on start-up.

Hope this helps,
Mat

Ok, so issue with standalone utility is irrelevant to ours. Thank you for hint about flag

I testedthat solution.

First, pvf_dll’s project didn’t had path setup, but I supplied it - I guess, it was determined by fact that it requires full path to .exe.

Second - it didn’t work. Setting pvf_dll as StartUp project and running Debug session resulted in Visual Studio hanging.

Edit:
Apparently, debug for that project didn’t worked at all, although program was compiled succefully. Even if I used pvf_calling_dll as StartUp. Next, I tried to copy project folder to other location, trying to check if issue is with folder permissions and way Win7 treats Program Files. Surprisingly, it failed to compile at all. Despite projects are identical, logs for pvf_dll are quite different and in relocated project it failed to generate .lib file and gave weird messages:

Succeful build

PVF Build Log
Begin rebuild: clean project
Deleting intermediate and output files for project 'pvf_dll', configuration 'Debug'

Compiling Project ...

sub1.f90

c:\program files (x86)\pgi\win32\12.10\bin\pgfortran.exe -Hx,123,8 -Hx,123,0x40000 -Hx,0,0x40000000 -Mx,0,0x40000000 -Hx,0,0x20000000 -g -Bdynamic -Mbackslash -Mfree -I"c:\program files (x86)\pgi\win32\12.10\include" -I"C:\Program Files\PGI\Microsoft Open Tools 10\include" -I"C:\Program Files\PGI\Microsoft Open Tools 10\PlatformSDK\include" -Minform=warn -module "Win32\Debug" -o "Win32\Debug\sub1.obj" -c "C:\Program Files (x86)\Microsoft Visual Studio 10.0\PGI Visual Fortran\Samples\dlls\pvf_dll\pvf_dll\sub1.f90"

Command exit code: 0


--------------------------------------------------------------------------------

Linking...

c:\program files (x86)\pgi\win32\12.10\bin\pgfortran.exe -Wl,/libpath:"c:\program files (x86)\pgi\win32\12.10\lib" -Wl,/libpath:"C:\Program Files\PGI\Microsoft Open Tools 10\lib" -Wl,/libpath:"C:\Program Files\PGI\Microsoft Open Tools 10\PlatformSDK\lib" -Wl,/libpath:"C:\Program Files (x86)\PGI\win32\12.10\lib" -Wl,/libpath:"C:\Program Files\PGI\win64\12.10\lib" -Yl,"C:\Program Files\PGI\Microsoft Open Tools 10\bin" -Mmakedll -g -Bdynamic -o "C:\Program Files (x86)\Microsoft Visual Studio 10.0\PGI Visual Fortran\Samples\dlls\pvf_dll\Win32\Debug\pvf_dll.dll" "Win32\Debug\sub1.obj" 

Command exit code: 0

Command output: [ Creating library C:\Program Files (x86)\Microsoft Visual Studio 10.0\PGI Visual Fortran\Samples\dlls\pvf_dll\Win32\Debug\pvf_dll.lib and object C:\Program Files (x86)\Microsoft Visual Studio 10.0\PGI Visual Fortran\Samples\dlls\pvf_dll\Win32\Debug\pvf_dll.exp ]

pvf_dll build succeeded.

Failed build

PVF Build Log
Begin rebuild: clean project
Deleting intermediate and output files for project 'pvf_dll', configuration 'Debug'

Compiling Project ...

Linking...

c:\program files (x86)\pgi\win32\12.10\bin\pgfortran.exe -Wl,/libpath:"c:\program files (x86)\pgi\win32\12.10\lib" -Wl,/libpath:"C:\Program Files\PGI\Microsoft Open Tools 10\lib" -Wl,/libpath:"C:\Program Files\PGI\Microsoft Open Tools 10\PlatformSDK\lib" -Wl,/libpath:"C:\Program Files (x86)\PGI\win32\12.10\lib" -Wl,/libpath:"C:\Program Files\PGI\win64\12.10\lib" -Yl,"C:\Program Files\PGI\Microsoft Open Tools 10\bin" -Mmakedll -g -Bdynamic -o "D:\Programming\Fortran\pvf_dll\Win32\Debug\pvf_dll.dll" "" 

Command exit code: 0

Command output: [LINK : warning LNK4001: no object files specified; libraries used LINK : warning LNK4068: /MACHINE not specified; defaulting to X86 ]

pvf_dll build succeeded.

Let’s back up and tackle the first problem you encountered, that of debugging Fortran code in a DLL when it is called from a VC++ main program.

PVF ships with a sample project that demonstrates this scenario. It is located here:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\PGI Visual Fortran\Samples\interlanguage\vcmain_calling_pvfdll

Using PVF 13.7 installed to VS 2010 Premium SP1 with VC++, I was able to build, run and debug this example. I used the Debug configuration and built both 32 and 64 bit platforms.

Is there a reason that you haven’t upgraded to 13.7? The example should also work in 12.10 but since you’ve encountered difficulty, perhaps this is the first thing that we should try.

If you’ve been working directly in the Samples directory, then before you upgrade please delete:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\PGI Visual Fortran\Samples

so that you get a clean set of examples when you install PVF 13.7.

Annemarie

Thank’s that cleans doubts.

Have subscription, just corporate stupidness.
That would require to upgrade entire enterprise to 13th version (it’s server lice license), for which I don’t have allowance or plan yet.
System is highly guarded , heh.

I solved second problem, apparently PVF project (at least in samples) store direct paths to object files and moving project to new location doesn’t work until certain changed made them. If its how they work with new projects then it’s wrong from point of team cooperation - e.g. same project on different machines might be in different places…

Debugger works and doesn’t work at random on x64 OS,depending which project I try, I can’t figure out yet what causes that. I made install on clean, non-network enabled machine x32 OS and it worked perfectly.

If you recommend to upgrade, I’ll try push it - I just need some reference to do - they are very conservative about it.

Unable to upgrade to 13.7 because it requires Visual Studio 2012, which isn’t our toolchain.


PS:
Path
C:\Program Files (x86)\Microsoft Visual Studio 10.0\PGI Visual Fortran\Samples\interlanguage\vcmain_calling_pvfdll
doesn’t exist in installation

Summary (after more thorough study and experimentation)

Effect of debugger crashing or hanging ALWAYS present if debugging C++ with fortran dll call, on any system I tried though

OSes: Windows 7 Pro x32 or x64 with SP1 , in Windows 2008 domain or standalone.