forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Create static libraries?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit
View previous topic :: View next topic  
Author Message
DietmarSiepmann



Joined: 03 Jun 2013
Posts: 279

PostPosted: Wed Mar 28, 2018 2:43 pm    Post subject: Create static libraries? Reply with quote

Hello,

I have learnt that slink64 (of ftn95 version 8.30) supports creating static libraries. Unfortunately I have not found any information/help how this would be done.

Having created a 64 bit object file xx.obj I tried calling slink64 with commands

archive xx.lib
addobj xx.obj
file

. However, this did not work, slink64 crashed with an access violation and displayed the follwing lines:
Comment: The 'archive' and 'addobj' commands are redundant
Loading C:\ds\sublib\salford64\xx.obj

Executing the same sequence of commands with slink (and a 32 bit object added) worked successfully and produced a static library xx.lib as expected. Moreover I am interested in the command line form of this command (using -archive:xx.lib etc.) which should be

slink64.exe -archive:xx.lib -addobj:xx.obj

Again this command produces no lib file but displays
[SLINK64 v2.01, Copyright (c) Silverfrost Ltd. 2015-2018]
***archive:xx.lib - unknown command.

How would I create a static library using slink64?

Thanks for any advice ...

Regards,
Dietmar
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Wed Mar 28, 2018 3:06 pm    Post subject: Reply with quote

Dietmar

Information is provided in ftn95.chm under x64 platform->Using the 64 bit linker.

Basically you just need to specify the correct extension. The default extension for a static library is .sl64 but you can use .lib if you prefer.

It is intended that you should be able to use some of the old SLINK commands, particularly in interactive mode. I will take a look at the ones that you have mentioned.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Wed Mar 28, 2018 3:15 pm    Post subject: Reply with quote

I think that you will find that it works if you use "archive" without the file name following.

I will make a note that the crash needs to be fixed.
Back to top
View user's profile Send private message AIM Address
DietmarSiepmann



Joined: 03 Jun 2013
Posts: 279

PostPosted: Wed Mar 28, 2018 3:42 pm    Post subject: Reply with quote

Paul,

having read in the documentation (file ftn95.chm) commands

lo xx.obj
file xx.sl64

should work for slink64, shouldn't they? But they do not.

Also removing the filename in the archive command does not work. To me it seems that the file command within slink64 produces the error. I am very interested in creating static libraries no matter how this would be done.

Regards,
Dietmar
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Wed Mar 28, 2018 3:58 pm    Post subject: Reply with quote

It works for me.

Are you using SLINK64 v2.01?

I tested both .sl64 and .lib.
Back to top
View user's profile Send private message AIM Address
DietmarSiepmann



Joined: 03 Jun 2013
Posts: 279

PostPosted: Thu Mar 29, 2018 11:07 am    Post subject: Reply with quote

Paul,

I used slink64 version 2.101 (Version string of slink64 call: [SLINK64 v2.01, Copyright (c) Silverfrost Ltd. 2015-2018]); I checked that the correct salflibc.dll was loaded by sdbg64 and it was (version id 20.3.16.7).

However, meanwhile I observed another phenomenon: I created a small sample (test_link.for) outside of our build environment for which I was able to create a lib in the way you suggested (compiling it to test_link.obj and then using slink64 to produce test_link.sl64).

In our build enviroment this mechanism does not work as I said. This is strange because I tried to create the library from a source file which had been compiled correctly to an object file and which could be linked to produce the final exe file. The compilation step did not produce any errors, but some warnings which I ignored. It is probably the object file which creates the problem for if I substitute it by test_link.obj, then the process works and produces the library intended.

I need to compare how the compilation steps differ.

Regards,
Dietmar
Back to top
View user's profile Send private message
DietmarSiepmann



Joined: 03 Jun 2013
Posts: 279

PostPosted: Tue Apr 03, 2018 3:49 pm    Post subject: Reply with quote

Paul,

meanwhile I could produce a sample where slink64 fails although an object file had been generated successfully.

Code:

C     Program generated
      SUBROUTINE SR1
     *(KSTEU)
      INTEGER*2 MYI2_1
      INTEGER*2 MYI2_2
         ...
      INTEGER*2 MYI2_94
      INTEGER*2 MYI2_95
      MYI2_1=1_2
      MYI2_2=1_2
         ...
      MYI2_94=1_2
      MYI2_95=1_2
      return
      end

Here ... means the corresponding statements to j=1 for j=3,4,5,...,92,93, respectively. The programme is named test_generated.for. Compiling via
Code:

ftn95 test_generated /64  /ALL_WARNINGS/NON_STANDARD/SINGLE_THREADED/OLD_ARRAYS/ALT_KINDS/PERSIST/UNLIMITED_ERRORS/FIXED_FORMAT/SAVE/NO_WARN73/WIDE_SOURCE

creates file test_generated.obj the size of which is 4.093 Bytes. Now trying to link via command
Code:

slink64 test_generated.lnk

with file test_generated.lnk defined as
Code:

lo test_generated.obj
file test_generated.lib

results in a crash producing error file
Code:

Access Violation
The instruction at address 100174fc attempted to read from location 102c1019

 1001743c read_bytes#2C [+00c0]
 10017716 __read [+02c3]
 1001d980 fread [+02b3]
 0040894c build_static_library(void) [+0148]
 00401000 main [+0f90]

eax=00001000   ebx=00000007   ecx=102c101a
edx=00000000   esi=00000007   edi=1018d644
ebp=0365eae0   esp=0365ea9c   IOPL=1
ds=002b   es=002b   fs=0053
gs=002b   cs=0023   ss=002b
flgs=00010212 [NC OP NZ SN DN NV]

 100174fc  movb     dl,[ecx-0x1]
 100174ff  movb     [ebp-0x15],dl
 10017502  mov      ebx,[ebp+0x8]

If you omit the 2 statements containing MYI2_95 in test_generated.for, the slink64 command is successful and creates archive test_generated.lib as expected.

Regards,
Dietmar
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Thu Apr 05, 2018 9:17 am    Post subject: Reply with quote

Dietmar

I have tested your latest sample and it works OK for me.

I don't know why. I am using FTN95 v8.30 and SLINK64 v2.01.
Back to top
View user's profile Send private message AIM Address
DietmarSiepmann



Joined: 03 Jun 2013
Posts: 279

PostPosted: Mon Apr 09, 2018 12:37 pm    Post subject: Reply with quote

Paul,

did you use the ftn95 Options mentioned above? I found that commands
Code:

ftn95 test_generated /64  /FIXED_FORMAT
slink64 test_generated.lnk


work and create the library expected, however, commands
Code:

ftn95 test_generated /64  /FIXED_FORMAT/SAVE
slink64 test_generated.lnk

do not work and produce the "Access Violation" error.

Regards,
Dietmar
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Apr 09, 2018 3:02 pm    Post subject: Reply with quote

Dietmar

It works for me with /SAVE and /FIXED.
I also tried FTN95 v8.20 and FTN95 v8.30 and it still works OK.
(My initial test was on the current developers' version.)

I anyone else willing to test this on their machine?
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Tue Apr 10, 2018 2:05 am    Post subject: Reply with quote

I have managed to get the test to work with Ver 8.30.
It takes a few files to build and run:

The library code : test_generated.for
Code:
! test_generated.for
!
!   sample library routine
!
       SUBROUTINE SR1
     * (KSTEU)
       integer   ksteu
       INTEGER*2 MYI2_1
       INTEGER*2 MYI2_2
!          ...
       INTEGER*2 MYI2_94
       INTEGER*2 MYI2_95

       MYI2_1=1_2
       MYI2_2=1_2
!          ...
       MYI2_94=1_2
       MYI2_95=1_2
       KSTEU = 42
       return
       end


The program to use the library : use_lib.for
Code:
!  use_lib.for   to user the library
!
C     Program generated
       integer   ksteu
      call SR1 (ksteu)
      write (*,*) 'The number is :',ksteu
      end


The slink file to build the library : test_gen.txt
Code:
lo test_generated.obj
file test_generated.sl64


The slink file to build the program : test_use.txt
Code:
lo use_lib.obj
lo test_generated.sl64
file use.exe

The batch file to do the test : build_gen.bat
Code:
del *.obj
del *.sl64

ftn95 test_generated /64  /ALL_WARNINGS/NON_STANDARD/SINGLE_THREADED/OLD_ARRAYS/ALT_KINDS/PERSIST/UNLIMITED_ERRORS/FIXED_FORMAT/SAVE/NO_WARN73/WIDE_SOURCE

slink64 @test_gen.txt

del test_generated.obj

ftn95 use_lib /64  /ALL_WARNINGS/NON_STANDARD/SINGLE_THREADED/OLD_ARRAYS/ALT_KINDS/PERSIST/UNLIMITED_ERRORS/FIXED_FORMAT/SAVE/NO_WARN73/WIDE_SOURCE

slink64 @test_use.txt

use


This worked for me, I hope it is correct
John
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Tue Apr 10, 2018 2:20 am    Post subject: Reply with quote

I expanded on the test with:
an extra library : test_gen2.for
Code:
! test_gen2.for
!
!   sample library routine
!
       SUBROUTINE SR2
     * (KSTEU)
       integer   ksteu
       INTEGER*2 MYI2_1
       INTEGER*2 MYI2_2
!          ...
       INTEGER*2 MYI2_94
       INTEGER*2 MYI2_95

       MYI2_1=1_2
       MYI2_2=1_2
!          ...
       MYI2_94=1_2
       MYI2_95=1_2
       KSTEU = 24
       return
       end


a new slink libarary build : test_gen.txt
Code:
lo test_generated.obj
lo test_gen2.obj
file test_generated.sl64


a new use program : use_lib.for
Code:
!  use_lib.for   to user the library
!
C     Program generated
       integer   ksteu
      call SR1 (ksteu)
      write (*,*) 'The number is :',ksteu
      call SR2 (ksteu)
      write (*,*) 'The number is :',ksteu
      end


a new slink for use : test_use.txt
Code:
lo use_lib.obj
lo test_generated.sl64
map use.map
file use.exe


and build : build_gen.bat
Code:
del *.obj
del *.sl64

ftn95 test_generated /64  /ALL_WARNINGS/NON_STANDARD/SINGLE_THREADED/OLD_ARRAYS/ALT_KINDS/PERSIST/UNLIMITED_ERRORS/FIXED_FORMAT/SAVE/NO_WARN73/WIDE_SOURCE
ftn95 test_gen2 /64  /ALL_WARNINGS/NON_STANDARD/SINGLE_THREADED/OLD_ARRAYS/ALT_KINDS/PERSIST/UNLIMITED_ERRORS/FIXED_FORMAT/SAVE/NO_WARN73/WIDE_SOURCE

slink64 @test_gen.txt

del test_generated.obj

ftn95 use_lib /64  /ALL_WARNINGS/NON_STANDARD/SINGLE_THREADED/OLD_ARRAYS/ALT_KINDS/PERSIST/UNLIMITED_ERRORS/FIXED_FORMAT/SAVE/NO_WARN73/WIDE_SOURCE

slink64 @test_use.txt

use


Commenting out "call SR2" shows in the .map that LO acts as LE for the library file in the build.

I hope this example is of use.
Back to top
View user's profile Send private message
DietmarSiepmann



Joined: 03 Jun 2013
Posts: 279

PostPosted: Thu Apr 12, 2018 4:09 pm    Post subject: Reply with quote

John,

I am not sure how to understand your lines
Code:

!          ...

. To make clear what I meant in my sample with the lines
Code:

         ...

please look at file create_static_libraries.bat following:
Code:

@echo off

setlocal

set MYCCOPTS=/FIXED_FORMAT/SAVE

if "%1" == "" (
  set UPPERBOUND=5
) else (
  set UPPERBOUND=%1
)

echo C     Program generated > test_generated.for
echo       SUBROUTINE SR1 >> test_generated.for
echo      *(KSTEU) >> test_generated.for
for /L %%J in (1,1,%UPPERBOUND%) do (
  echo       INTEGER*2 MYI2_%%J >> test_generated.for
)
for /L %%J in (1,1,%UPPERBOUND%) do (
  echo       MYI2_%%J=1_2 >> test_generated.for
)
echo       KSTEU=%UPPERBOUND% >> test_generated.for
echo       return >> test_generated.for
echo       end >> test_generated.for

if exist test_generated.obj del test_generated.obj
if exist test_generated.sl64 del test_generated.sl64

echo ftn95 test_generated /64  %MYCCOPTS%
ftn95 test_generated /64 %MYCCOPTS% > test_generated.log 2>&1

echo lo test_generated.obj > test_gen.txt
echo file test_generated.sl64 >> test_gen.txt

echo slink64 @test_gen.txt
slink64 @test_gen.txt
if ERRORLEVEL 1 (
  echo Could not create archive test_generated.sl64
  exit /B 1
)

echo C use_lib.for   to use library test_generated.sl64 > use_lib.for
echo C >> use_lib.for
echo C     Program generated >> use_lib.for
echo       integer   ksteu >> use_lib.for
echo       character*1 c1 >> use_lib.for
echo       call SR1 (ksteu) >> use_lib.for
echo       write (*,*) 'The number is :',ksteu >> use_lib.for
echo       write(*,*) 'Enter any key to exit' >> use_lib.for
echo       read(1,'(A1)') c1 >> use_lib.for
echo       end  >> use_lib.for

echo ftn95 use_lib /64 %MYCCOPTS%
ftn95 use_lib /64 %MYCCOPTS%

echo lo use_lib.obj > test_use.txt
echo lo test_generated.sl64 >> test_use.txt
echo file use.exe >> test_use.txt

if exist use.exe del use.exe
echo slink64 test_use.txt
slink64 @test_use.txt

echo .\use.exe
.\use.exe

endlocal

If you execute this batch file, then the following files are created:
Code:

test_generated.for
test_generated.obj
test_generated.log
test_gen.txt
test_generated.sl64
use_lib.for
use_lib.obj
test_use.txt
use.exe

and file use.exe is ececuted and lines
Code:

The number is :           5
Enter any key to exit

are displayed. In order to verify which SALFORD DLLs have been loaded you may want to make use of the resource manager. It turns out that Dlls clearwin64.dll and salflib64.dll of ftn95 version 8.30 have been loaded as expected. You may exit programme use.exe by typing any key followed by the ENTER key.

Now you may call create_static_libraries.bat with an integer paramater (>5) to increase the number declarations an assignments in file test_generated.for (genarated by the batch file). In my environment, call
Code:

create_static_libraries.bat 93

works ok and executable use.exe creates the line
Code:

The number is :          93

. However, calling
Code:

create_static_libraries.bat 94

does not work and does not create static library test_generated.sl64.
Back to top
View user's profile Send private message
DietmarSiepmann



Joined: 03 Jun 2013
Posts: 279

PostPosted: Thu Apr 12, 2018 4:59 pm    Post subject: Reply with quote

John,

I am sorry, but I accidently submitted the last post before proofreading. To be sure about the source you used could you please execute call
Code:

create_static_libraries.bat 94

in a new directory and tell me if this works?

Moreover, I don't understand why you expandend the test with extra library test_gen2.lib. What do you mean with "that LO acts as LE for the library file"?

John and Paul,

I wonder if slink64 might have problems with the size of the object file generated. When calling batch create_static_libraries.bat with parameter 94, the size of object file test_generated.obj is 4.070 bytes. Have you been able to create static libraries from object files with sizes greater than 4.070 bytes?

Thanks in advance for any help.

Regards,
Dietmar
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Thu Apr 12, 2018 8:12 pm    Post subject: Reply with quote

I now have enough information to see that there is a problem.
I have made a note that we need to investigate further.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group