Compiling Autolisp Files
Compiling Autolisp Files
by Kenny Ramage
Visual Lisp provides you with the ability to create a single, standalone executable module for your application. This
module incorporates all your application's compiled files, and can include DCL, DVB, and other files that your
application may need. Executable Visual Lisp modules are known as VLX files, and are stored in files named with
a .vlx extension.
A Make Application wizard guides you through the application building process in Visual Lisp. The result of this
process is a Make file, which is often referred to by its file extension, .prv. The Make file contains all the instructions
Visual Lisp needs to build the application executable.
To test this out, I've provided an AutoLisp Application that consists of an AutoLisp file, and a DCL file. From these 2
files we will compile one VLX executable module. (Just click here to download the source files). Unzip these files
and save them in any directory within your AutoCAD Support Path.
OK, fire up AutoCAD and open the Visual LISP Editor from the Applications panel of the Manage tab on the ribbon.
Now select "Files" - "Make Application" - "New Application" from the pulldown menu :
Select "Expert" mode as we want to compile multiple file types, and then press "Next" :
Enter the path to the directory you would like to store the files in. Select the same directory that you stored the
AutoLisp source files. Then, give your application a name. It does not have to be the same as your AutoLisp source
file, but to spare any confusion, let's keep it the same.
No, we do not want our application to run in a separate namespace. Just select "Next" :
Now we need to select our AutoLispsource file. Select "refl.lsp" then press "Next" :
In this dialog, we select and add any dependency files that our application needs to run correctly. Select "refl.dcl"
and then "Next" :
No need to confuse you now, just go with the "Standard" option. Select "Next" :
OK, that's us about done. To build your compiled application, just select "Finish".
VLISP executes instructions in a Make file to build an application. Output messages from this process appear in two
VLISP windows: the Build Output window and the Console window. The Build Output window contains messages
relating to any compilation of AutoLISP source code into .fas files. In a successful compile, the output looks like the
following :
; (COMPILE-FILES st
(D:/drawings/refl.lsp))
[Analyzing file "D:/drawings/refl.lsp"]
..
......
[COMPILING D:/drawings/refl.lsp]
;
;;C:REFL
;CCC
;;MKLIST
;;SPINBAR
;;INITERR
;;TRAP
;;RESET
;
[FASDUMPING object format -> "D:/drawings/refl.fas"]
; Compilation complete.
The name and directory path of the source files being compiled.
The functions defined in the source file. Seven functions are identified: C:REFL, CCC, MKLIST, SPINBAR, INITERR,
TRAP and RESET.
Have a look in the directory where you stored the source files. You should now have 5 "refl" files :
Loading compiled applications is exactly the same as for normal AutoLisp functions :
(load "refl")
If you do not specify a file extension, load first looks for a file with the name you specified (for example, "refl"), and
an extension of .vlx. If no .vlx file is found, load searches next for a .fas file, and finally, if no .fas file is found, load
searches for a .lsp file.
VLISP Project
To aid you in the process of maintaining multiple-file applications, VLISP provides a construct called a Project. A
VLISP Project contains a list of AutoLISP source files, and a set of rules on how to compile the files.
Check which .lsp files in your application have changed, and automatically recompile only the modified files. This
procedure is known as a Make procedure.
Simplify access to source files by listing all source files associated with a project, making them accessible with a
single-click.
Help you find code fragments by searching for strings when you do not know which source files contain the text
you're looking for. VLISP limits the search to files included in your project.
Optimize compiled code by directly linking the corresponding parts of multiple source files.
Have a look at the Visual Lisp Help for further information on Projects.