Using the 64 bit linker

The SINK64 command line

SLINK64 can be used in 3 ways...

1) It can use a series of commands from a file (recommended). The commands are placed in a file with the .inf or .link suffix, and is invoked thus:

   SLINK64 file.inf 


   SLINK64 @file.inf

     A $ symbol may be used as an alternative to @.

2) It can be used interactively, using the same commands as in (1).

3) It can be used from the command line. This can be derived from the command specifications.
    Thus the command lo can be coded on the command line as /lo (obj file)


SLINK64 commands

load(lo) <file> Loads the file, which must be FTN95/SCC 64-bit object code.
rlo <file> Loads the file for a DLL with delayed binding. The file must be FTN95/SCC 64-bit object code.
map <file> Requests a link map, to be placed in the specified file. If the file argument is omitted, the map is placed in a file whose name is derived from the name of the DLL or EXE file being created.
file <exe or dll file> Completes the linking operation and puts the result in the given file name. Note that the choice of suffix (DLL or EXE) determines the type of file created. Currently all entry points in the code are exported in the case of a DLL.
windows This command forces the creation of a WINDOWS application, which does not use a console. This is normally used in conjunction with ClearWin+ code.
load(lo) <file.dll> Uses the entry points in the specified DLL to satisfy calls in the code. The DLL must be avaible at run-time.
load(lo) <file.res> Loads a resource file created with SRC using the /r switch. This is the same SRC command used in 32-bit mode except that the /r switch must be used.
image_base <hex address> Specifies the base address for the link (not normally required, and can be overwritten at run time by Windows).
stack_size <hex number> Specifies the stack size. The default value is 0x2000000 (32 MB).
alias <name> <alias> Sets up an alias to an external name when making a DLL. Note that the names are case sensitive. This was added to enable gFortran to call a DLL built with FTN95. It circumvents the problem that gFortran uses lower case names while FTN95 uses upper case names! It may have other specialised uses.
insert <file> Provides the path of a text file that is to be included in the script.
help Prints out abbreviated help information to the console.
quit(q) Quits SLINK64 without saving anything.


Typical use
SLINK64 is automatically called when /link or /lgo is used on the FTN95 command line. The name of the executable or DLL can be supplied after /link (this is optional for executables but mandatory for DLLs). Also /stack can be included followed by the stack size as a number of megabytes. /map can also be used in this context. The WINAPP directive in the Fortran code creates a Windows application and this directive can optionally be followed by the name of a resource script. Alternatively a resource script can be included by placing the script after the main program by using the RESOURCES directive.

Here are the required SLINK64 commands for five slightly more complicated scenarios:

1) To link a simple program that uses a DLL: The file (say) ExtraDLL.dll is scanned for entry points but it isn't incorporated in MyProgram.exe - so MyProgram.exe will require the DLL somewhere on the path at runtime.

  lo MyProgram.obj 
  lo ExtraDLL.dll 
  file MyProgram.exe 

2) To link a number of files to create a DLL that exports all subroutine/function names:

  lo file1.obj 
  lo file2.obj 
  lo file3.obj 
  file MyLibrary.dll 

3) To create a windows program with some ClearWin+ code that uses resources: The resources are prepared by:

   SRC MyResources.rc /r 

Then the SLINK64 commands are:

  lo MyProgram.obj 
  lo MyResources.res 
  file MyProgram.exe 

4) To create a static library of object code:

  lo sub1.obj
  lo sub2.obj
  lo sub3.obj
  file MyStaticLibrary.sl64 

Note that files with the suffix .sl64 are static libraries made by SLINK64.

5) To use a static library, simply load it:

  lo main.obj
  lo MyStaticLibrary.sl64
  file result.exe

It is important to load a static library after any code that may reference the code within it, otherwise items that have not been referenced at the time the library is loaded, will not be included in the resultant file. A static library can be used in the creation of a DLL.

If you load a static library into a SLINK64 session that is itself creating a static link library, this will merge the entire contents of the library into the resultant library. It is even possible for both libraries to have the same name - in which case the library is updated with whatever other components are loaded by SLINK64.

Note that SLINK64 can make three different types of files - executable files (.EXE), dynamic link libraries (.DLL) and static libraries (.SL64), and that this is entirely determined by the suffix on the output file specified by the file command. If no suffix is supplied, .EXE is assumed.

Compatibility with SLINK
Most of the commands provided in the 32 bit linker SLINK can also be used with SLINK64. So users who are familiar with SLINK can usually use the same commands with SLINK64. In particular the SLINK commands 'dll', 'archive' and 'addobj', can also be used with SLINK64.

Copyright © 1999-2021 Silverfrost Limited