2008-08-24 15 views
57

मैं सिर्फ लिस्प सीखने शुरू कर दिया है और मैं समझ नहीं संकलन और एक निष्पादन के लिए तुतलाना कोड कैसे लिंक करें।लिस्प निष्पादन

मैं clisp उपयोग कर रहा हूँ और clisp -c दो फ़ाइलों का उत्पादन:

  • .fas
  • उदारीकरण

करते हैं तो क्या मैं एक निष्पादन तक ले जाने वाला हो?

+0

चलाने के लिए कॉल (मुख्य) को इसके बजाय आप 'compile-file' का उपयोग कर सकते हैं। –

उत्तर

47

मैं वास्तव में यह आज क्या करने की कोशिश कर रहा था, और मैं टाइपिंग CLisp आरईपीएल में इस पाया काम किया:

(EXT:SAVEINITMEM "executable.exe" 
       :QUIET t 
       :INIT-FUNCTION 'main 
       :EXECUTABLE t 
       :NORC t) 

समारोह के नाम पर आप कॉल करने के लिए जब चाहते हैं, जहां मुख्य है प्रोग्राम लॉन्च, :QUIET t स्टार्टअप बैनर को दबाता है, और :EXECUTABLE t मूल निष्पादन योग्य बनाता है।

यह भी आदेश जब प्रोग्राम किया जाता है एक इंटरैक्टिव तुतलाना शीघ्र प्राप्त करने से उपयोगकर्ता को रोकने के लिए

(EXT:EXIT) 
अपने मुख्य कार्य के अंत में

कॉल करने के लिए उपयोगी हो सकता है।

संपादित करें: प्रलेखन पढ़ना, आप :NORC t (link पढ़ सकते हैं) जोड़ना भी चाह सकते हैं। यह आरसी फ़ाइल लोड करने के लिए दबाता है (उदाहरण के लिए, ~/.clisprc.lisp)।

+0

मैक ओएस एक्स 10.9 पर सीसीएल पर मुझे निष्पादन योग्यता में समस्या है। '(सेव-एप्लिकेशन"/पूर्ण/पथ/से/सहेजे गए ऐप ": प्रीपेन्ड-कर्नेल टी)' उत्पादित निष्पादन योग्य फ़ाइल पर डबल क्लिक करने से टर्मिनल पर प्रवेश होता है जो त्रुटि की तरह एक से शुरू होने वाली बहुत लंबी त्रुटियों को दिखाता है: समस्या लोडिंग बंडल: कक्षा का नाम निर्धारित नहीं कर सकता और कर्नेल डीबगर विकल्पों के साथ समाप्त हो सकता है। विंडोज़ पर सीसीएल पर मैं बस एक फ़ंक्शन को परिभाषित करता हूं और निष्पादन योग्य को बचाने के लिए उपरोक्त करता हूं, बाद में मैं आउटपुट फ़ाइल को डबल क्लिक कर सकता हूं और मेरे परिभाषित फ़ंक्शन को याद कर सकता हूं, मैक पर सीसीएल भी याद नहीं रखता है जब मैं छवि को सहेजता हूं और इसे मैन्युअल रूप से कर्नेल में लोड करता हूं –

35

यह एक Lisp FAQ (थोड़ा अनुकूलित) है:

*** How do I make an executable from my programme?

This depends on your implementation; you will need to consult your vendor's documentation.

  • With ECL and GCL, the standard compilation process will produce a native executable.

  • With LispWorks, see the Delivery User's Guide section of the documentation.

  • With Allegro Common Lisp, see the Delivery section of the manual.

  • etc...

However, the classical way of interacting with Common Lisp programs does not involve standalone executables. Let's consider this during two phases of the development process: programming and delivery.

Programming phase: Common Lisp development has more of an incremental feel than is common in batch-oriented languages, where an edit-compile-link cycle is common. A CL developer will run simple tests and transient interactions with the environment at the REPL (or Read-Eval-Print-Loop, also known as the listener). Source code is saved in files, and the build/load dependencies between source files are recorded in a system-description facility such as ASDF (which plays a similar role to make in edit-compile-link systems). The system-description facility provides commands for building a system (and only recompiling files whose dependencies have changed since the last build), and for loading a system into memory.

Most Common Lisp implementations also provide a "save-world" mechanism that makes it possible to save a snapshot of the current lisp image, in a form which can later be restarted. A Common Lisp environment generally consists of a relatively small executable runtime, and a larger image file that contains the state of the lisp world. A common use of this facility is to dump a customized image containing all the build tools and libraries that are used on a given project, in order to reduce startup time. For instance, this facility is available under the name EXT:SAVE-LISP in CMUCL, SB-EXT:SAVE-LISP-AND-DIE in SBCL, EXT:SAVEINITMEM in CLISP, and CCL:SAVE-APPLICATION in OpenMCL. Most of these implementations can prepend the runtime to the image, thereby making it executable.

Application delivery: rather than generating a single executable file for an application, Lisp developers generally save an image containing their application, and deliver it to clients together with the runtime and possibly a shell-script wrapper that invokes the runtime with the application image. On Windows platforms this can be hidden from the user by using a click-o-matic InstallShield type tool.

3

यह करने के लिए एक पोर्टेबल तरीका के लिए, मैं roswell सलाह देते हैं।

किसी भी समर्थित कार्यान्वयन के लिए आप प्रोग्राम चलाने के लिए लिस्पी स्क्रिप्ट बना सकते हैं जिसे ros द्वारा पोर्टेबल तरीके से चलाया जा सकता है जिसका उपयोग एक हैथ-बैंग लाइन में एक पायथन या रूबी प्रोग्राम के समान ही किया जा सकता है।

SBCL और सीसीएल Roswell के लिए भी ros dump executable के साथ द्विआधारी निष्पादनयोग्य बना सकते हैं।

+0

यह क्यों कम किया गया था? – Thayne

0

;; मैं जानता हूँ कि यह एक पुराने सवाल है, लेकिन लिस्प कोड मैं देख रहा हूँ 25 वर्ष :-)

है मैं संकलन विंडोज 10 पर clisp के साथ काम हालांकि नहीं मिल सका है, यह GCL

साथ मेरे लिए काम किया

https://www.cs.utexas.edu/users/novak/gclwin.html

;; मेरी lisp फ़ाइल jugs2 है। lisp

gcl -compile jugs2.lisp ;; यह jugs2 फ़ाइल को jugs2.o बनाता है।lisp फ़ाइल में कोई त्रुटि नहीं है

;; lisp दुभाषिया gcl

;; .o फ़ाइल लोड करें

(load "jugs2.o")

;; एक exe

(si:save-system "jugs2")

;; जब exe चलाया जाता है तो उसे dll oncrpc.dll की आवश्यकता होती है ;; यह \ lib \ gcl-2.6.1 \ unixport फ़ोल्डर में है जो gcl.bat बनाता है।

;; जब इसे चलाया जाता है तो यह एक लूप वातावरण दिखाता है, मुख्य फ़ंक्शन (मुख्य)