NO

Author Topic: PNL Scientific Library CRASHES  (Read 1619 times)

Offline milen_prg

  • Member
  • *
  • Posts: 6
PNL Scientific Library CRASHES
« on: May 06, 2023, 04:00:52 PM »
I try to use this:
https://pnlnum.github.io/pnl/
with Pelles C. It depends only from libpnl.dll, which depends on libblas.dll, liblapack.dll.

It compiles without any problem with mingw64 gcc, but in Pelles C:

I use Pelles C compiler (Windows 10 Pro 64 bit) and try to compile simple example:

`#include <stdio.h>
#include <pnl/pnl_complex.h>

int main(int argc, char *argv[])
{
dcomplex z = Complex(-1, 0);
printf("%f\n", Csqrt(z).r);
return 0;
}
`

The compilation and linking is successful. Program exe starts with or without dlls. But crashes immediately at function Complex().

The IDE gives this messages:

C:\Users\mlap\Documents\pellesCmath1\pellesCmath1.exe.
POLINK: warning: Section '.idata$7' is not supported; image will probably not run.
POLINK: warning: Section '.idata$7' is missing contents flag; assuming DATA.
POLINK: warning: Section '.idata$5' is missing contents flag; assuming DATA.
POLINK: warning: Realigned section '.idata$5' in object 'libpnl.lib(0 1673985086 501 20 644 261 d†�)' (from 4 to 8 byte(s)). POLINK: warning: Section '.idata$4' is missing contents flag; assuming DATA. POLINK: warning: Realigned section '.idata$4' in object 'libpnl.lib(0              1673985086  501   20    644     261     
d†�)' (from 4 to 8 byte(s)).
POLINK: warning: Section '.idata$6' is missing contents flag; assuming DATA.
POLINK: warning: Section '.idata$7' is missing contents flag; assuming DATA.
POLINK: warning: Section '.idata$5' is missing contents flag; assuming DATA.
POLINK: warning: Realigned section '.idata$5' in object 'libpnl.lib(0 1673985086 501 20 644 261 d†�)' (from 4 to 8 byte(s)). POLINK: warning: Section '.idata$4' is missing contents flag; assuming DATA. POLINK: warning: Realigned section '.idata$4' in object 'libpnl.lib(0              1673985086  501   20    644     261     
d†�)' (from 4 to 8 byte(s)).
POLINK: warning: Section '.idata$6' is missing contents flag; assuming DATA.
POLINK: warning: Section '.idata$2' is missing contents flag; assuming DATA.
POLINK: warning: Realigned section '.idata$2' in object 'libpnl.lib(0 1673985086 501 20 644 261 d†�)' (from 4 to 1 byte(s)). POLINK: warning: Section '.idata$5' is missing contents flag; assuming DATA. POLINK: warning: Realigned section '.idata$5' in object 'libpnl.lib(0              1673985086  501   20    644     261     
d†�)' (from 4 to 8 byte(s)).
POLINK: warning: Section '.idata$4' is missing contents flag; assuming DATA.
POLINK: warning: Realigned section '.idata$4' in object 'libpnl.lib(0 1673985086 501 20 644 261 d†�)' (from 4 to 8 byte(s)). POLINK: warning: Section '.idata$4' is missing contents flag; assuming DATA. POLINK: warning: Realigned section '.idata$4' in object 'libpnl.lib(0              1673985086  501   20    644     261     
d†�)' (from 4 to 8 byte(s)).
POLINK: warning: Section '.idata$5' is missing contents flag; assuming DATA.
POLINK: warning: Realigned section '.idata$5' in object 'libpnl.lib(0 1673985086 501 20 644 261 `
d†�)' (from 4 to 8 byte(s)).
POLINK: warning: Section '.idata$7' is missing contents flag; assuming DATA.

Can you give some advice how to debug this and to try to make pnl library to work with this compiler.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2099
Re: PNL Scientific Library CRASHES
« Reply #1 on: May 06, 2023, 10:57:22 PM »
The import library libpnl.lib probably includes unsupported sections. The DLL should be effective anyway.
You should create a new import library from libpnl.dll using polib.exe with the command:
Code: [Select]
polib libpnl.dll /MACHINE:X64 /OUT:libpnl.libI have created the new import library, attached to the post, and compiled your code. It seems to work.
Let me know...
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Offline Don D

  • Member
  • *
  • Posts: 2
Re: PNL Scientific Library CRASHES
« Reply #2 on: May 06, 2023, 11:25:09 PM »
I can confirm the same results as frankie. I had used polink to create a new libpnl.lib, and it worked fine on both PellesC v11 and v12RC2. In PellesC v12RC2 I noticed 2 extra harmless warnings regarding realigned sections from 4 to 8 bytes.

I assume you've added a path to your pnl lib, a path to your pnl includes, and libpnl.lib to your linker's library and object files.

BTW, on a PellesC v11 system, I used...
Code: [Select]
polib libpnl.dll /list... on a copy of libpnl.dll in a new directory, just to preserve the original libpnl.lib.

Offline milen_prg

  • Member
  • *
  • Posts: 6
Re: PNL Scientific Library CRASHES
« Reply #3 on: May 07, 2023, 08:59:25 AM »
Thank, you, thank, you, very, very much!
This works! I would never find that, may be it even is not in the documentation! I play with applied software development, understand almost nothing in system software.

One notice:
The generated libpnl.lib with the command:
polib libpnl.dll /list
works, BUT there are 2 warnings:
POLINK: warning: Realigned section '.idata$5' in object 'libpnl.lib(libpnl.dll)' (from 4 to 8 byte(s)).
POLINK: warning: Realigned section '.idata$4' in object 'libpnl.lib(libpnl.dll)' (from 4 to 8 byte(s)).

The generated libpnl.lib with the command:
polib libpnl.dll /MACHINE:X64 /OUT:libpnl.lib
works without any warnings, so I use this command!

The two generated libpnl.lib files are with the same size (much smaller than the original), but are different in binary content.

Thank, you, again! Now I have power math lib for Pelles C.
« Last Edit: May 07, 2023, 09:05:24 AM by milen_prg »

Offline Vortex

  • Member
  • *
  • Posts: 805
    • http://www.vortex.masmcode.com
Re: PNL Scientific Library CRASHES
« Reply #4 on: May 07, 2023, 11:46:09 AM »
Hi milen_prg,

In the module definition file pnl.def, correct the first line as the following :

Code: [Select]
LIBRARY libpnl
Building the import library from the module definition file :

Code: [Select]
\PellesC\bin\polib.exe /MACHINE:x64 /DEF:pnl.def /OUT:libpnl.lib
Code it... That's all...

Offline milen_prg

  • Member
  • *
  • Posts: 6
Re: PNL Scientific Library CRASHES
« Reply #5 on: May 07, 2023, 12:34:00 PM »

In the module definition file pnl.def, correct the first line as the following :
Code: [Select]
LIBRARY libpnl
Building the import library from the module definition file :
Code: [Select]
\PellesC\bin\polib.exe /MACHINE:x64 /DEF:pnl.def /OUT:libpnl.lib

Yes, this works perfect. Will use this as may be most correct way. Thanks!

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2099
Re: PNL Scientific Library CRASHES
« Reply #6 on: May 07, 2023, 12:51:28 PM »
One notice:
The generated libpnl.lib with the command:
polib libpnl.dll /list
works, BUT there are 2 warnings:
POLINK: warning: Realigned section '.idata$5' in object 'libpnl.lib(libpnl.dll)' (from 4 to 8 byte(s)).
POLINK: warning: Realigned section '.idata$4' in object 'libpnl.lib(libpnl.dll)' (from 4 to 8 byte(s)).

The generated libpnl.lib with the command:
polib libpnl.dll /MACHINE:X64 /OUT:libpnl.lib
works without any warnings, so I use this command!
Basically both commands works the same because the default action is to create the import library. The /LIST switch simply also shows on the console the exported entries.
The machine type, 32 or 64 bits, is deducted from the DLL if not explicitly indicated with the switch /MACHINE:x64. The sections alignments are copied from the original (this DLL is aligned on 32bits boundary by the compiler used), generating the polink warnings. But if the switch is used the import library alignment are fixed on 64bits boundary.
Using a DEF file is another method, but be advised, in some cases, specifically on 32bits objects, where different calling conventions existed, a malformed def file, or formed for a different compiler, can alias the symbols, making impossible the link. In the worst case linking with wrong convention that leads to a crash...
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide