Linking ANSYS binlib.dll


I am trying to make an executable with PGI out of the f90 demo routines that read the results binary file (.rst for example) of an ANSYS analysis. The routines are well documented and explained, but need to be linked to a DLL (binlib.dll) present in the ANSYS distribution. Originally the DLL has been compiled with the Intel compiler, and I have found no way to access the object files in the DLL neither with PGI nor with gcc. Can you help me ? Thank.

Regards, Marco.

Hi Marco,

Unfortunately ANSYS does not compile their windows product with PGI and therefore their DLL will not be compatible with our compilers. There is no cure for that. Perhaps direct your question to ANSYS how to fix the problem would get a better answer.


Hallo Hongyon,

I have made some steps further, and I think I am probably close to the solution. In the ANSYS distribution there is also a binlib.lib file, that if renamed as libbinlib.a under Cygwin helps solving the linking issue with C++. In this simple C/C++ program I call one subroutine of ANSYS, binini,

extern “C” int BININI(int *);

int main() {

int i;



Compiling it with pgcpp (-Munix) and linking it against the libbinlib.a it works very fine. The nm command issued on the .obj file,

00000000 b .bss
00000000 d .data
00000000 t .text
U __main
00000000 d __orig_esp
U __pgimain
00000000 T _main
00000000 t pgCC_compiled.

shows that the famous underscore is now only at the beginning of the upper case name. Now, the equivalent F90 program, compiled with -Munix,

program simple

external BININI

call BININI(10)


produces a table of names like,

00000004 d .C1_283
00000000 d .C1_298
00000000 b .bss
00000000 d .data
00000000 d .pgi_trace
00000000 t .text
00000010 T MAIN
0000004d t ___MAIN_END
U binini
U _pgf90_compiled
U _pgf90_exit
00000020 C _pghpf_0l
U _pghpf_init


1 - the underscore is now both at the beginning and at the end of the subroutine name
2 - the name is lower case.

I have searched in the documentation but I could not find the compiler flags solving the problem. You can probably help me very fast.

Thanks, Marco

Hi Marco,

  1. I insisted that it will not work if binlib.lib you have is an imported library and it is to be used to link in your program and you will still need binlib.dll to run, meaning you need both. Renaming to liblib.a won’t work, you can’t use it as a standalone library. Yes, you can link but can’t run.

  2. I don’t know that the calling convention they use to compile dll, but it may not work/compatible. Normally on win32 we use stdcall, but if you use -Munix, calling convention will be the same as Unix and I am quite sure it will not work with their libraries. Even if you have it linked you will probably get wrong answer or seg fault somewhere because calling convention are not compatible.

If you want to try resolve the naming problem, use $DEC ATTRIBUTES DLLIMPORT,ALIAS ‘_BININI’::binini. There should more information on DEC ATTRIBUTES out there.

Again I insisted that it will just link but not run or run incorrectly.

  1. There will be a lot of work in your program to work around naming issues.

I insisted you ask ANSYS for a solution.