1SWI(1)                      General Commands Manual                     SWI(1)
2
3
4

NAME

6       swipl-ld - Create a SWI-Prolog embedded executable
7

SYNOPSIS

9       swipl-ld options c-files o-files pl-files
10

DESCRIPTION

12       The  utility  swipl-ld  is a front-end for the C-compiler and linker to
13       create a stand-alone executable from a series of C/C++ and Prolog input
14       files.  It  extracts  information from the SWI-Prolog executable swipl,
15       after which it scans the arguments and breaks them into  several  cate‐
16       gories.   It then calls the C-compiler to create an executable contain‐
17       ing the user's C-code and the SWI-Prolog kernel.  After this,  it  will
18       call  the  development  environment to create a Prolog saved state from
19       the prolog files and finally it will create the  target  executable  by
20       concatenating the state to the emulator.  See also qsave_program/2 from
21       the SWI-Prolog manual.
22
23
24   Options
25       -pl prolog
26              Specifies the prolog version to  use.   The  default  is  swipl.
27              This  flag  may  be  used  to  choose between different versions
28              installed on your system, or to specify a modified  version.   A
29              modified  version  should  understands  the flags -dump-runtime-
30              variables -f file -F file -g goal -t toplevel.
31
32       -help  Shows options briefly
33
34       -nostate
35              Just relinks the kernel.  The newly linked kernel can only func‐
36              tion  in  the  presence of the development system.  Any supplied
37              prolog sourcefiles are ignored, and so  are  the  options  -goal
38              -toplevel -initfile.  -class This is the preferred way to attach
39              external modules to Prolog if dynamic loading is  not  supported
40              on your system.
41
42       -c     Compile  C  or  C++  source-files into object files.  This turns
43              swipl-ld into a replacement for the  C  or  C++  compiler  where
44              proper options such as the location of the include directory are
45              passed automatically to the compiler.
46
47       -E     Invoke the C preprocessor.  Used to make swipl-ld a  replacement
48              for the C or C++ compiler.
49
50       -shared
51              Link  C, C++ or object files into a shared object (DLL) that can
52              be loaded by the load_foreign_library/1 predicate.  If used with
53              -c  it  sets the proper options to compile a C or C++ file ready
54              for linking into a shared object.
55
56       -embed-shared
57              Embed SWI-Prolog into a DLL/Shared object rather  than  an  exe‐
58              cutable.  See the reference manual for details.
59
60       -dll   Windows only Same as -embed-shared Backward compatibility.
61
62       -F base
63              By  default,  none  is passed to the swipl command to create the
64              saved state.  Using -F xpce you  can  specify  loading  xpce.rc,
65              making XPCE available to the saved state.
66
67       -goal goal
68              The goal that is initially executed when the toplevel is started
69              using PL_toplevel().  E.i. the default.  -g  flag  for  the  new
70              executable.
71
72       -toplevel goal
73              The  goal  that is executed as the main toplevel goal.  E.i. the
74              default.  -t flag for the new executable.
75
76       -initfile file
77              The file that is loaded by the toplevel.  E.i. the default.   -f
78              flag for the new executable.
79
80       -class {runtime,kernel,development}
81              Set  the  save-class  of the Prolog saved-state that is created.
82              If runtime (default), the resulting system leave  interpretation
83              of  all  arguments to the application.  If kernel all predicates
84              will be locked for the  tracer.   Finally,  if  development  the
85              state  is  saved  `as-is'  and  the  resulting  system processes
86              options just as the basic SWI-Prolog executable does.  See  also
87              qsave_program/2 in the SWI-Prolog reference manual.
88
89       -v     Verbose  operation.   This  echos  the commands before executing
90              them.  Note that some commands are printed  as  shell  commands,
91              but  actually executed by swipl-ld itself for compatibility with
92              the Win32 platforms.
93
94       -f     Fake operation.  Together with -v this prints the commands  that
95              need to be executed without actually doing anything.
96
97       -Ecppargument ...
98              If  the  first option is -E, all subsequent options are appended
99              and handed to the program selected by  SWI-Prolog  configure  to
100              run cpp.
101
102       -o file
103              Specifies  the  name  of  the  final executable.  The default is
104              a.out.
105
106       -cc C-compiler
107              Specify the compiler to use for *.c files.  Default is the  com‐
108              piler  used  to compile SWI-Prolog itself, as read from the fea‐
109              ture c_cc.
110
111       -c++ C++-compiler
112              Specify the compiler to use for C++ input files.  If the  C-com‐
113              piler is gcc this is g++, otherwise c++ is assumed.
114
115       -ld linker
116              Specifies  the  linker  to  use.  Default is the C-compiler.  On
117              Win32 platforms, the default is link.exe.
118
119       -llibrary
120              Specifies a C-library for linking the application.  By  default,
121              -lswipl as well as the libraries required by the SWI-Prolog ker‐
122              nel will be passed to the C-compiler.
123
124       -Llibrary-directory
125              Specifies an additional library directory  for  the  C-compiler.
126              By  default,  the runtime directory for the current architecture
127              is passed.
128
129       -g|-I*|-D*|-U*|-O*|-W*
130              Passed to the compiler as c-flags.  By default,  the  SWI-Prolog
131              include  directory  is  passed  as additional include directory.
132              The following -D flags are added by  swipl-ld:  -D__SWI_PROLOG__
133              and -D__SWI_EMBEDDED__.
134
135       -pl-options*
136              Specify  additional options for swipl.  The first character fol‐
137              lowing -pl-options determines the option-separator.  The remain‐
138              der  of the argument is split using this separator and the parts
139              are added to the option list for Prolog.  See  also  -cc-options
140              and -ld-options
141
142       -ld-options*
143              Additional  options  passed  to  the  linker.  For example: -ld-
144              options,-Bstatic
145
146       -cc-options*
147              Additional options passed to both C- and C++-compiler.
148
149       *.o    Passed as input files to the linker.
150
151       *.c    Compiled using the C-compiler, after which  the  object-file  is
152              passed to the linker.  The object file is deleted at cleanup.
153
154       *.cc|*.C|*.cxx|*.cpp
155              Compiled  using the C++-compiler, after which the object-file is
156              passed to the linker.  The object file is deleted at cleanup.
157
158       *.pl|*.qlf
159              Passed as Prolog input files
160

BUGS

162       Parsing the options and distributing them over the various programs  is
163       probably  incomplete.  Feel free to modify it and please forward gener‐
164       ally useful modifications to bugs@swi-prolog.org.
165
166       Some care has to be taken that the state created  with  qsave_program/2
167       is   self-contained   (i.e.   contains  no  references  to  the  Prolog
168       libraries).  Also, as the state is created using the development  envi‐
169       ronment  rather  then  the  user's emulator, the Prolog code cannot use
170       directives that rely on the C-code added by the user.
171

SEE ALSO

173       swipl(1) SWI-Prolog Reference Manual, http://www.swi-prolog.org
174
176       Copyright (C) 1991-2010, University of Amsterdam, VU  University,  Ams‐
177       terdam  This program may be used under the terms of the LGPL, version 2
178       or later.
179

AUTHOR

181       Jan Wielemaker
182
183
184
185                                  Feb 8, 2006                           SWI(1)
Impressum