The MASM Forum

General => The Workshop => Topic started by: jj2007 on October 10, 2015, 02:43:39 PM

Title: GNU Scientific Library
Post by: jj2007 on October 10, 2015, 02:43:39 PM
I am testing if there is a n00b-friendly way of installing & using the GSL (http://www.gnu.org/software/gsl/). The attached proggie will show a MsgBox saying gsl_INIT error, and if you click OK, shortly after you should see another box Success: Bessel function etc...

Grateful for some tests - AV problems etc 8)
Title: Re: GNU Scientific Library
Post by: hutch-- on October 10, 2015, 04:47:58 PM
Same result here, could not find the lib, downloaded in from Sourceforge.
Title: Re: GNU Scientific Library
Post by: TWell on October 10, 2015, 06:03:36 PM
gsl-1.15-dev-win32 here (https://code.google.com/p/oscats/downloads/detail?name=gsl-1.15-dev-win32.zip&can=2&q=)
gsl-1.15-dev-win64 here (https://code.google.com/p/oscats/downloads/detail?name=gsl-1.15-dev-win64.zip&can=2&q=)
Title: Re: GNU Scientific Library
Post by: jj2007 on October 10, 2015, 07:36:46 PM
Quote from: hutch-- on October 10, 2015, 04:47:58 PM
Same result here, could not find the lib, downloaded in from Sourceforge.

And it worked then and showed the Bessel value, I hope?

@Tim: Thanks for the link, looks like the latest version. Much bigger, of course, and I wonder what kind of setup problems that means - XP compatible, for example? ::)

Btw what was the name of the tool in \Masm32\bin\*.exe that allowed to extract all exports from a DLL?
Title: Re: GNU Scientific Library
Post by: hutch-- on October 10, 2015, 07:55:35 PM
JJ,

Clive's "dumppe".

Command line.

\masm32\bin\dumppe -disasm yourdll.dll > lst.txt
Title: Re: GNU Scientific Library
Post by: GoneFishing on October 10, 2015, 08:04:18 PM
or you may try this
QuoteLINK /DUMP /EXPORTS YOUR.DLL
or this
QuoteDUMPBIN /EXPORTS YOUR.DLL

There's one excellent  tool set : http://www.ntcore.com/exsuite.php

P.S.: GSL is well documented : GNU Scientific Library – Reference Manual (http://www.gnu.org/software/gsl/manual/html_node/)
Title: Re: GNU Scientific Library
Post by: jj2007 on October 10, 2015, 08:55:46 PM
@Hutch: That produces a 25 MB listing, not a list of exports

@GoneFishing: Both commands work fine, and produce practically the same output

In the meantime, I found my own routine, see attachment, which produces a plain listing.
Usage: GetDllExports YourDll.dll
With e.g. getdllexports C:\Windows\System32\msvcr*.dll you can get an idea what the differences between these DLLs are.

Re GSL, the *blas versions are identical but the main lib has been somewhat expanded:
1.8 -> 6.7 MB
3695 -> 4173 functions

Will reflect whether to switch to the new one or not... fight the bloat  8)

Quote from: GoneFishing on October 10, 2015, 08:04:18 PMP.S.: GSL is well documented : GNU Scientific Library – Reference Manual (http://www.gnu.org/software/gsl/manual/html_node/)

Indeed :t

Currently, in the MasmBasic manual I point to another site:

include \masm32\MasmBasic\MasmBasic.inc      ; download (http://www.masm32.com/board/index.php?topic=12460)
; libgsl.dll download (http://gnuwin32.sourceforge.net/packages/gsl.htm): open Binaries zip, and extract libgsl.dll and libgslcblas.dll to \masm32\MasmBasic\GnuScLib\DLL
; define the gsl function(s) you want to use with the syntax of the GNU Scientific Library Reference (http://www.gnu.org/software/gsl/manual/gsl-ref.html)
gslvar      int gsl_rng_default()
gsl      double gsl_stats_mean (const double data[], size_t stride, size_t n)
gsl      double gsl_stats_variance (const double data[], size_t stride, size_t n)
gsl      double gsl_stats_sd (const double data[], size_t stride, size_t n)
... etc ...


The two pages look almost identical (one has a horizontal line, the other doesn't ::)). Again I will have to test which version works better.
Title: Re: GNU Scientific Library
Post by: hutch-- on October 10, 2015, 10:42:26 PM
JJ,

Just open the file in a text editor, you get the PE header then all imports and exports.
Title: Re: GNU Scientific Library
Post by: jj2007 on October 11, 2015, 01:23:29 AM
Quote from: hutch-- on October 10, 2015, 10:42:26 PMJust open the file in a text editor, you get the PE header then all imports and exports.

Sure. This is what I wanted (my tool, 108kB):
_gsl_sf_bessel_amp_phase_bm0_cs
_gsl_sf_bessel_amp_phase_bm1_cs
_gsl_sf_bessel_amp_phase_bth0_cs
_gsl_sf_bessel_amp_phase_bth1_cs
gsl_acosh
gsl_asinh
gsl_atanh
...


This is what you get from dumppe (50MB, scroll down a little bit to find gsl_acosh):
libgsl-0.dll                       (hex)           (dec)

.EXE size (bytes)                    490            1168
Minimum load size (bytes)            450            1104
Overlay number                         0               0
Initial CS:IP                  0000:0000
Initial SS:SP                  0000:00B8             184
Minimum allocation (para)              0               0
Maximum allocation (para)           FFFF           65535
Header size (para)                     4               4
Relocation table offset               40              64
Relocation entries                     0               0

Portable Executable starts at                 80
Signature                               00004550 (PE)
Machine                                     014C (Intel 386)
Sections                                    0014
Time Date Stamp                         4EAECA7E Mon Oct 31 17:19:10 2011
Symbol Table                            005EAC00
Number of Symbols                       00004D99
Optional header size                        00E0
Characteristics                             2106
Executable Image
Line numbers stripped
32 bit word machine
DLL
Magic                                       010B
Linker Version                              2.21
Size of Code                            00147A00
Size of Initialized Data                001F6200
Size of Uninitialized Data              00000400
Address of Entry Point                  00001058
Base of Code                            00001000
Base of Data                            00149000
Image Base                              6EEC0000
Section Alignment                       00001000
File Alignment                          00000200
Operating System Version                    4.00
Image Version                               1.00
Subsystem Version                           4.00
reserved                                00000000
Image Size                              005F5000
Header Size                             00000600
Checksum                                00667AC8
Subsystem                                   0003 (Console)
DLL Characteristics                         0000
Size Of Stack Reserve                   00200000
Size Of Stack Commit                    00001000
Size Of Heap Reserve                    00100000
Size Of Heap Commit                     00001000
Loader Flags                            00000000
Number of Directories                   00000010

Directory Name                          VirtAddr  VirtSize
--------------------------------------  --------  --------
Export                                  001CA000  00023C72
Import                                  001EE000  0000117C
Resource                                00000000  00000000
Exception                               00000000  00000000
Security                                00000000  00000000
Base Relocation                         001F2000  0000A238
Debug                                   00000000  00000000
Decription/Architecture                 00000000  00000000
Machine Value (MIPS GP)                 00000000  00000000
Thread Storage                          001F1000  00000018
Load Configuration                      00000000  00000000
Bound Import                            00000000  00000000
Import Address Table                    001EE300  0000029C
Delay Import                            00000000  00000000
COM Runtime Descriptor                  00000000  00000000
(reserved)                              00000000  00000000

Section Table
-------------
01  .text    Virtual Address         00001000
Virtual Size            00147840
Raw Data Offset         00000600
Raw Data Size           00147A00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         60300060
Code
Initialized Data
4    Byte Align
Executable
Readable

02  .data    Virtual Address         00149000
Virtual Size            0000CA80
Raw Data Offset         00148000
Raw Data Size           0000CC00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         C0600040
Initialized Data
32   Byte Align
Readable
Writeable

03  .rdata  Virtual Address         00156000
Virtual Size            0002E8E0
Raw Data Offset         00154C00
Raw Data Size           0002EA00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         40600040
Initialized Data
32   Byte Align
Readable

04  /4      Virtual Address         00185000
Virtual Size            00043A00
Raw Data Offset         00183600
Raw Data Size           00043A00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         40300040
Initialized Data
4    Byte Align
Readable

05  .bss    Virtual Address         001C9000
Virtual Size            00000220
Raw Data Offset         00000000
Raw Data Size           00000000
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         C0600080
Uninitialized Data
32   Byte Align
Readable
Writeable

06  .edata  Virtual Address         001CA000
Virtual Size            00023C72
Raw Data Offset         001C7000
Raw Data Size           00023E00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         40300040
Initialized Data
4    Byte Align
Readable

07  .idata  Virtual Address         001EE000
Virtual Size            0000117C
Raw Data Offset         001EAE00
Raw Data Size           00001200
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         C0300040
Initialized Data
4    Byte Align
Readable
Writeable

08  .CRT    Virtual Address         001F0000
Virtual Size            00000018
Raw Data Offset         001EC000
Raw Data Size           00000200
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         C0300040
Initialized Data
4    Byte Align
Readable
Writeable

09  .tls    Virtual Address         001F1000
Virtual Size            00000020
Raw Data Offset         001EC200
Raw Data Size           00000200
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         C0300040
Initialized Data
4    Byte Align
Readable
Writeable

0A  .reloc  Virtual Address         001F2000
Virtual Size            0000A238
Raw Data Offset         001EC400
Raw Data Size           0000A400
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42300040
Initialized Data
4    Byte Align
Discardable
Readable

0B  /14      Virtual Address         001FD000
Virtual Size            00003F50
Raw Data Offset         001F6800
Raw Data Size           00004000
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

0C  /29      Virtual Address         00201000
Virtual Size            0000033C
Raw Data Offset         001FA800
Raw Data Size           00000400
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

0D  /45      Virtual Address         00202000
Virtual Size            00000452
Raw Data Offset         001FAC00
Raw Data Size           00000600
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

0E  /61      Virtual Address         00203000
Virtual Size            001A86FA
Raw Data Offset         001FB200
Raw Data Size           001A8800
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

0F  /73      Virtual Address         003AC000
Virtual Size            0002FE92
Raw Data Offset         003A3A00
Raw Data Size           00030000
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

10  /87      Virtual Address         003DC000
Virtual Size            00059C5E
Raw Data Offset         003D3A00
Raw Data Size           00059E00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

11  /99      Virtual Address         00436000
Virtual Size            00000450
Raw Data Offset         0042D800
Raw Data Size           00000600
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42300040
Initialized Data
4    Byte Align
Discardable
Readable

12  /112    Virtual Address         00437000
Virtual Size            000036FD
Raw Data Offset         0042DE00
Raw Data Size           00003800
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

13  /123    Virtual Address         0043B000
Virtual Size            0019E76C
Raw Data Offset         00431600
Raw Data Size           0019E800
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable

14  /134    Virtual Address         005DA000
Virtual Size            0001AD08
Raw Data Offset         005CFE00
Raw Data Size           0001AE00
Relocation Offset       00000000
Relocation Count        0000
Line Number Offset      00000000
Line Number Count       0000
Characteristics         42100040
Initialized Data
1    Byte Align
Discardable
Readable


Exp Addr Hint   Ord Export Name by libgsl-0.dll - Mon Oct 31 17:19:09 2011
-------- ---- ----- ---------------------------------------------------------
0012B04C    0     1 GSL_MAX_DBL
0012B02C    1     2 GSL_MAX_INT
0012B084    2     3 GSL_MAX_LDBL
0012B068    3     4 GSL_MIN_DBL
0012B03C    4     5 GSL_MIN_INT
0012B0A0    5     6 GSL_MIN_LDBL
0012B0F4    6     7 GSL_MODE_PREC
00177E40    7     8 _gsl_sf_bessel_amp_phase_bm0_cs
00177E00    8     9 _gsl_sf_bessel_amp_phase_bm1_cs
00177E20    9    10 _gsl_sf_bessel_amp_phase_bth0_cs
00177DE0    A    11 _gsl_sf_bessel_amp_phase_bth1_cs
0012B338    B    12 gsl_acosh
0012B438    C    13 gsl_asinh
0012B59C    D    14 gsl_atanh

;)
Title: Re: GNU Scientific Library
Post by: TWell on October 11, 2015, 02:24:26 AM
In this forum many things are done in hard way (stupid).
I have seen easy way to do things in PellesC forum.
Title: Re: GNU Scientific Library
Post by: dedndave on October 11, 2015, 05:31:50 AM
we appreciate your vote of confidence, Tim - lol

although, it makes me wonder why you are here
Title: Re: GNU Scientific Library
Post by: rrr314159 on October 11, 2015, 06:32:52 AM
Quote from: TWellIn this forum many things are done in hard way (stupid).

- reminds me of my favorite (slightly risque) bumper sticker,

"Assembly programmers do it the hard way"

Perhaps it should have a coda, "... because they're stupid!" That's a good idea, women (I've noticed) find stupidity very attractive :biggrin:
Title: Re: GNU Scientific Library
Post by: TWell on October 11, 2015, 06:33:20 AM
To learn something from experts, like you.
And what's wrong to use program like this: http://vortex.masmcode.com/files/dll2defV11.zip
Title: Re: GNU Scientific Library
Post by: hutch-- on October 11, 2015, 08:46:24 AM
 :biggrin:

JJ,

If you don't want the disassembly, don't add the command line option "-disasm".
Title: Re: GNU Scientific Library
Post by: jj2007 on October 11, 2015, 10:15:02 AM
Quote from: TWell on October 10, 2015, 06:03:36 PM
gsl-1.15-dev-win32 here (https://code.google.com/p/oscats/downloads/detail?name=gsl-1.15-dev-win32.zip&can=2&q=)

Thanks for the hint, Tim. I've made it the new default in MasmBasic version 11 October (http://masm32.com/board/index.php?topic=94.0). You can override it with gsl_OldVersion=1.

Quote from: TWell on October 11, 2015, 02:24:26 AM
In this forum many things are done in hard way (stupid).
I have seen easy way to do things in PellesC forum.

That is an interesting observation. Of course, we are struggling to make things easier:
2.1 An Example Program (from the GSL manual (http://www.gnu.org/software/gsl/manual/gsl-ref.html#An-Example-Program))

The following short program demonstrates the use of the library by computing the value of the Bessel function J_0(x) for x=5,

#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>

int
main (void)
{
  double x = 5.0;
  double y = gsl_sf_bessel_J0 (x);
  printf ("J0(%g) = %.18e\n", x, y);
  return 0;
}

The output is shown below, and should be correct to double-precision accuracy,2

J0(5) = -1.775967713143382920e-01

The steps needed to compile this program are described in the following sections.

( etc etc ... there it gets complicated ...)


Now the MasmBasic equivalent:

include \masm32\MasmBasic\MasmBasic.inc      ; download (http://masm32.com/board/index.php?topic=94.0)
  gsl double gsl_sf_bessel_J0 (double x)     ; double x means a pointer to a REAL8 is required
  Init
  Print Str$("Bessel function for a value of 5 = %Jf\n", gsl_sf_bessel_J0(FP8(5.0)))
EndOfCode


Output:
Bessel function for a value of 5 = -0.1775967713143382920

Compiling instructions see Masm32: What you absolutely must know to get started (http://www.webalice.it/jj2006/Masm32_Tips_Tricks_and_Traps.htm), including step 6

So what would you suggest to make it less hard?

Just for fun, another example - a graphical representation of a Bessel function:

GuiParas equ "Bessel function", x20, y20, w1200, h700
include \masm32\MasmBasic\Res\MbGui.asm
  gsl double gsl_sf_bessel_J0(double x)   ; see GSL manual (http://www.gnu.org/software/gsl/manual/gsl-ref.html#Regular-Modified-Cylindrical-Bessel-Functions)
  SetGlobals fct:REAL8
  gsl_INIT
  Dim Bessel1() As REAL8
  xor ecx, ecx            ; array index
  For_ fct=-10.0 To 40.0 Step 0.05
      SetFloat Bessel1(ecx)=gsl_sf_bessel_J0(fct)
      inc ecx
  Next
Event Paint
  ArrayPlot hWnd, RgbCol(20, 255, 240)      ; define canvas and background colour
  ArrayPlot Bessel1()
  ArrayPlot exit, "GSL: Regular cylindrical Bessel function of zeroth order"
GuiEnd
Title: Re: GNU Scientific Library
Post by: Farabi on October 11, 2015, 10:40:16 PM
Quote from: TWell on October 11, 2015, 02:24:26 AM
In this forum many things are done in hard way (stupid).
I have seen easy way to do things in PellesC forum.

Well, I have no idea how do stupid defined. Most of us, will called people stupid based on our surrounding and then some people had no idea what we`re talking about, mostly that`s what stupid is. But, when are talked about comercial software, not a hobby in order to understand something, learning the hard way is considered as stupid. End user need something quick, and cheap, something that are hobbyist cant afford to make.

But, when are talked about understand, which mean, knowing the working principle, I dont consider it as stupid.

It`s a matter of perspective though.
Title: Bessel functions
Post by: jj2007 on October 15, 2015, 04:47:30 AM
I have no idea what they are good for, but the Bessel functions do look nice :biggrin:

  xor ecx, ecx            ; array index
  For_ fct=-10.0 To 40.0 Step 0.04
      SetFloat Bessel0(ecx)=gsl_sf_bessel_J0(fct)
      SetFloat Bessel1(ecx)=gsl_sf_bessel_Jn(1, fct)
      SetFloat Bessel2(ecx)=gsl_sf_bessel_Jn(-3, fct)
      inc ecx
  Next
Title: Re: GNU Scientific Library
Post by: LiaoMi on October 19, 2017, 09:32:13 AM
Hi,

by github link you can find the latest version 2.5 for Windows, which is well compiled in the latest Microsoft Visual Studio 2017, libraries, examples, versions for both x64 and x32 systems. The only thing, I did not have time to test it. 

GSL 2.5 Sources VS2017

https://github.com/BrianGladman/gsl  (https://github.com/BrianGladman/gsl)

GSL 2.2 with MSVC Headers
For Visual Studio Community MSVC 2017 (Release, 64 bits)
gsl_2_2_msvc2017_64.zip (7.7 MB)
For Visual Studio Community MSVC 2015 (Release, 64 bits)
gsl_2_2_msvc2015_64.zip (7.8 MB)
For Visual Studio Community MSVC 2015 (Release, 32 bits)
gsl_2_2_msvc2015_32.zip (7.2 MB)
GSL 2.1
For Visual Studio Community MSVC 2015 (Release, 32 bits)
gsl_2_1_msvc2015_32.zip (1.6 MB)
GSL 1.16
For Visual Studio Community MSVC 2015 (Release, 64 bits)
gsl_1_16_msvc2015_64.zip (5.5 MB)
For Visual Studio Community MSVC 2015 (Release, 32 bits)
gsl_1_16_msvc2015_32.zip (5.1 MB)

https://www.bruot.org/hp/libraries/  (https://www.bruot.org/hp/libraries/)
Title: Re: GNU Scientific Library
Post by: jj2007 on October 19, 2017, 05:26:54 PM
Any link to libgsl.dll and libgslcblas.dll binaries? Compiling them myself really is not an option.
Title: Re: GNU Scientific Library
Post by: LiaoMi on October 19, 2017, 07:38:09 PM
Quote from: jj2007 on October 19, 2017, 05:26:54 PM
Any link to libgsl.dll and libgslcblas.dll binaries? Compiling them myself really is not an option.

Hi,

Here is a complete build of the latest source with examples and all libraries
https://mega.co.nz/#!El5QQCLQ!AAAAAAAAAAA0MuXuJxLT1gAAAAAAAAAANDLl7icS09Y

version earlier, can be downloaded in the second link, there was version 2.2 with libraries but without examples - https://www.bruot.org/hp/media/files/libraries/gsl_2_2_msvc2017_64.zip and https://www.bruot.org/hp/media/files/libraries/gsl_2_2_msvc2015_32.zip
Title: Re: GNU Scientific Library
Post by: jj2007 on October 19, 2017, 09:50:48 PM
Great stuff, LiaoMi. Can I use the two DLLs for my GSL examples?
Title: Re: GNU Scientific Library
Post by: LiaoMi on October 19, 2017, 11:10:37 PM
Quote from: jj2007 on October 19, 2017, 09:50:48 PM
Great stuff, LiaoMi. Can I use the two DLLs for my GSL examples?

Sure! :biggrin: So it was planned  :P