CoCreate Modeling FAQ: Lisp compiler


How do I compile Lisp code?

To compile Lisp code, use the compile-file command:

  (compile-file "somepath/yourlispfile.lsp")

Make sure to open the console window before compilation (View/Console) because you will find diagnostic information there. The resulting DLL will be generated in the current directory.

In order to use compile-file, you must install the Integration Kit beforehand. This is a separate option in the installation program; use custom installation mode to select this option. You will also need an Integration Kit license for the compiler.

Under the hood, the Lisp compiler uses Microsoft's Visual C++ to create the object code. Therefore, you must make sure to install the right version of Visual C++ on your system before running the Lisp compiler. The Integration Kit documentation will tell you which version is required - see below.

Under HP-UX, HP's aCC compiler is required.

Wie übersetze ich Lisp-Code?

Um Lisp-Code zu übersetzen, benutzt man das Kommando compile-file:

  (compile-file "irgendeinpfad/lispdatei.lsp")

Vorher sollte man das Konsolenfenster geöffnet haben (Ansicht/Konsole), weil dort wichtige Diagnosemeldungen ausgegeben werden. Die erzeugte DLL findet man dann im aktuellen Verzeichnis.

Um compile-file benutzen zu können, muß man vorher das Integration Kit installieren. Das ist eine eigene Option im Installationsprogramm von CoCreate Modeling; man wähle eine benutzerangepaßte Installation und dann darin die Option für das Integration Kit. Außerdem braucht man für den Compiler auch eine Integration-Kit-Lizenz.

Intern verwendet der Lisp-Compiler Microsoft Visual C++, um den Objektcode zu erzeugen. Daher muß man die passende Version von Visual C++ installieren, bevor man den Lisp-Compiler benutzen kann. Die Dokumentation zum Integration Kit gibt die jeweils benötigte Version des C++-Compilers an - siehe weiter unten.

Unter HP-UX wird der Compiler aCC von HP verwendet.

-- ClausBrod - 23 Dec 2004


Which version of Visual C++ is required to compile Lisp code for my version of CoCreate Modeling?

Visual C++ version recommendations can be found in the Integration Kit online help documentation (Documentation for advanced users" / "Integration Kit" / "Introduction").

The following table lists recommendations for a few versions of CoCreate Modeling:

CoCreate Modeling Visual C++
2004 Visual C++ 6.0
2005 VS.NET 2003
2006/v14.0x for 32-bit systems VS.NET 2003
2006/v14.0x for 64-bit systems Visual Studio 2005
2006/v14.50 for 32-bit and 64-bit systems Visual Studio 2005
2008 Visual Studio 2005???
17 Visual C++ 2008 SP1
18.1 Visual C++ 2010

Welche Version von Visual C++ brauche ich, um Lisp-Code für meine Version von CoCreate Modeling zu übersetzen?

Empfehlungen für die passende Version von Visual C++ findet man in der Hilfe zum Integration Kit (Documentation for advanced users" / "Integration Kit" / "Introduction").

Die obige Tabelle führt Empfehlungen für einige Versionen von CoCreate Modeling auf.

-- ClausBrod - 22 Jun 2018


How do I load a compiled Lisp file?

The same way as an uncompiled file, i.e. using the load command:

  (load "somepath/compiledlispfile")

If a file called compiledlispfile.dll (HP-UX: compiledlispfile.so) is in the specified path, this will load it.

Wie lade ich ein übersetztes Lisp-File?

Genauso wie ein noch nicht übersetztes, nämlich mit dem Kommando load:

  (load "irgendeinpfad/compiledlispfile")

Wenn es eine Datei namens compiledlispfile.dll (HP-UX: compiledlispfile.so) im angegebenen Pfad gibt, wird sie hiermit geladen.

-- ClausBrod - 23 Dec 2004


Compiling a Lisp file using compile-file fails, and I get a strange Lisp error message

If the Lisp error is "The function COMPILE-FILE is undefined.", then you need to install the Integration Kit first. Start the installation program and add this component to your installation. (You'll need to use "custom" installation mode.)

There is also another class of potential Lisp errors which look like this:

   LISP error:
   (SYSTEM ("SDLCPAS3" "-" "c:\\temp" -o" ...)) returned a non-zero value 3.

If you see this ultra-cryptic error message, it means that compilation of the Lisp code has failed. As a first step to find out what is happening, open the console window (View/Console), then try to compile the Lisp file again. You will sometimes get more informative error output in the console window. The most frequent problems are:

  • To compile Lisp code into a DLL, a C++ compiler is required. CoCreate Modeling assumes that a copy of Visual C++ is installed on the system, and that the compiler and linker can be executed by calling the executables cl.exe and link.exe, respectively. CoCreate Modeling runs those programs via the system command shell; in order to find the programs, the command shell searches all directories which are specified in the PATH environment variable. If cl.exe and link.exe cannot be found in any of the directories in PATH, compilation will fail.

    Sometimes, Visual C++ does not add the required directories to PATH during installation, or does so only for the user who installs the software, but not for any other users of the system.

    Even worse, not only the PATH environment variable, but also the LIB and INCLUDE environment variables must be set correctly during Visual C++ installation.

    The easiest fix for this is to reinstall Visual C++ on the system, and making sure that it adds itself to the environment variables for the user(s) who later want to compile Lisp code.

  • Lisp compilation will only work reliably with the version of Visual C++ which is specified in the Integration Kit documentation. The table above lists CoCreate Modeling versions and corresponding versions of Visual C++.

The error code in the message above ("...retured a non-zero value n") actually contains useful information about the type of compilation issue:

Error code What it means What you can do about it
1 Script called with wrong arguments. Check parameters to the compile-file command
2 Clsp file not found (error in compiler front-end)  
3 C++ compilation error Check settings for environment variables, see below
4 Linker error Check correct compiler/linker installation
5 C++ compiler version on the system is not supported. Check correct compiler/linker installation

Here's a simple method to test the compiler installation: Open a DOS shell window, then enter "cl". If you get an error message such as "cl is not recognized as an internal or external command", either there is no compiler installation on the system, or the PATH environment variable does not include references to the compiler installation directories.

If the compiler is found, it will report its version and display usage information:

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

The above is the expected output for VS.NET 2003, which is required to compile Lisp files for CoCreate Modeling 2005.

Now check if the environment variables PATH, INCLUDE and LIB are set correctly. Open a DOS shell window and check those environment variables. The following captures a DOS shell session on my system (where VS.NET 2003 is installed):

c:\temp>echo %INCLUDE%
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\include\;
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\Include;
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\ATLMFC\Include;
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include

c:\temp>echo %LIB%
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Lib\;
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\Lib;
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\ATLMFC\Lib;
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib

c:\temp>path
PATH=....someotherdirectories...
c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE;
c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools;
c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\Bin;
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\Bin;
c:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin;

-- ClausBrod, last updated 2006/11/27


When loading a compiled Lisp file, I get an "Initializer function not found" message.

  • Is the compilation environment set up correctly? For example, you must make sure that you are using a C++ compiler which matches the version of CoCreate Modeling you are using (see above for details).
  • Maybe the Lisp file was compiled in a different version of CoCreate Modeling. While interpreted Lisp code is largely compatible across versions, the same is not necessarily true for compiled code.
  • Never rename a compiled Lisp file. If you need to rename the DLL, rename the *.lsp file first, then re-compile.
  • Double-check the character cases in your filename e.g. Foobar.lsp can compile into foobar.dll especially when using a samba like server.
  • Do not use backslashes in path specifications for the compile-file command:
      (compile-file "c:/temp/foobar.lsp")         ;; OK
      (cd "c:/temp")(compile-file "foobar.lsp")   ;; OK
      (compile-file "c:\\temp\\foobar.lsp")       ;; won't work

Beim Laden einer übersetzten Lisp-Datei bekomme ich eine Fehlermeldung "Initializer function not found"

  • Ist die Compilerumgebung richtig eingerichtet? Beispielsweise ist es wichtig, daß der verwendete C++-Compiler zur Version von CoCreate Modeling paßt (siehe oben).
  • Möglicherweise ist die Lisp-Datei in einer anderen Version von CoCreate Modeling übersetzt worden. Interpretierter Lisp-Code ist zwar über Versionen hinweg ausführbar, übersetzter Code aber nicht unbedingt.
  • Übersetzte Lisp-Dateien darf man nicht umbenennen! Wenn ein neuer Name doch einmal sein muß, so benennt man zuerst die *.lsp-Datei um und übersetzt dann noch einmal neu.
  • Vorsicht vor Fehlern bei der Groß/Kleinschreibung. Wenn man beispielsweise auf einem Samba-Laufwerk eine Datei Foobar.lsp übersetzt, kann daraus je nach Samba-Konfiguration foobar.dll werden.
  • In Pfadangaben für das Kommando compile-file darf man kein Backslash-Zeichen verwenden:
      (compile-file "c:/temp/foobar.lsp")         ;; OK
      (cd "c:/temp")(compile-file "foobar.lsp")   ;; OK
      (compile-file "c:\\temp\\foobar.lsp")       ;; führt zu Ladefehler

-- ClausBrod (with contribution from JohnVanDoorn) - 11 February 2005


When asked for a TWiki account, use your own or the default TWikiGuest account.

to top

You are here: CoCreateModeling > OsdmFaq > OsdmFaqLispCompiler

r1.7 - 22 Jun 2018 - 19:26 - ClausBrod to top

CoCreateModeling
CoCreate ModelingRSS
FAQ
  Introduction
  Hardware
  Operating system
  Memory management
  File handling
  Installation
  Licensing
  Graphics
  App. knowhow
  Lisp
    Learning
    Programming
    Debugging
    DDE
    Compiler
    Customization
  Troubleshooting
  Links
Code examples
Viewbench
News
Changes
Index
Search
Impressum
Home

  • My links
  • Show me topics of interest

TWiki

Welcome


TWiki Web TWiki Web Home Changes Topics Index Search


TWiki Webs Atari Blog Main OneSpaceModeling? Sandbox TWiki TWiki Webs Atari Blog Main OneSpaceModeling? Sandbox TWiki

Jump:

Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback