Failure to create C++ DLL with pgcpp

I’m trying to compile a C++ DLL on Windows 7 using PGI 14.7, and it’s failing to create the DLL exports. I can create the DLL with no exports, but that’s not very useful.

Whether I specify __declspec(dllexport) directly in the code, or use a module DEF file at link time, I always get similar errors where pgmunch is failing.

Here’s my compile and link command lines:

pgcpp -fast -acc 360API.cpp 360APIStdAfx.cpp ImageProcessor.cpp ImageProcessorCAPI.cpp ImageProcessorCommon.cpp -Wl,/DLL -Bstatic -c -m64

pgcpp -fast -acc -Mmakedll 360API.obj 360APIStdAfx.obj ImageProcessor.obj ImageProcessorCAPI.obj ImageProcessorCommon.obj -o 360API.dll -Wl,/DLL -Bstatic -defaultlib:libaccg -defaultlib:libaccg2 -m64

And the eventual error:
“C:/Program Files/PGI/win64/14.7/bin\pgmunch.exe” -f SOLARIS -o C:\Users\Sentry360\AppData\Local\Temp\pgcpp4czKdlM42T_t4.s C:\Users\Sentry360\AppData\Local\Temp/pgcpp2ajKdBed6LcZl.dll
pgcpp-Fatal-munchexe completed with exit code -1073740940

No idea what ‘-f SOLARIS’ is all about, I haven’t been able to find any documentation about pgmunch at all.

If I specify the dllexport directly in the code and omit the -def= link directive, I get the same pgmunch error.

Any help would be great, as I’m knocking my head against a wall at the moment.

Even using the very simple example from the Compiler User’s Guide as C++ instead of C:

#include <stdio.h>

extern "C"
{
int __declspec(dllexport) data;
void __declspec(dllexport)
func2(int i)
{
 printf("func2: data == %d\n", data);
 printf("func2: i == %d\n", i);
 data = i;
}
}

pgcpp -fast -acc obj.cpp -Wl,/DLL -Bstatic -c -m64
pgcpp -fast -acc -Mmakedll obj.obj -o obj.dll -Wl,/DLL -Bstatic -m64 -v

Results in the same pgmunch error.

Hi Erik,

You need to use dynamic compilation in order to create DLLs. Unfortunately due to some runtime library limitations, we don’t support -Bdynamic with C++, and hence, you can’t use pgcpp to create DLLs.

  • Mat

So what you’re saying is… we would have to rewrite our application in C in order to compile a Windows DLL?

No, just that pgcpp doesn’t support creating of DLLs. If you need to create a DLL from C++, you would need to use a different compiler. Unfortunately we haven’t seen the demand that would justify the work necessary to add this support.

Sorry,
Mat

In our case, that’s exactly what it means unfortunately. We have a C++ DLL component that we were hoping to use the PGI Accelerator Compiler to add GPU acceleration to the compute intensive portions of the code. Not being able to use pgcpp to compile the DLL means we have to rewrite the module in C, extract the compute functions to a separate C DLL, or not use the PGI Accelerator Compiler at all. Our module wasn’t written with GPU acceleration in mind, so it’s not something designed directly for CUDA and the like.