Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes, it is possible. You can check the announcement on the <a href="http://www.red-lang.org/2013/08/033-released-shared-libraries-and.html" rel="noreferrer">Red-Blog for 0.3.3</a></p> <p>First of all, here is a short snippet describing the process for <strong>Red/System</strong>:</p> <blockquote> <p>Shared lib generation</p> <p>Since a year, we were working on bringing shared library generation, now it is available in the main branch. New features were added to support library generation like a way to declare the exported symbols and special callback functions when loading and freeing the library. Here is a simple example of a Red/System library:</p> <pre><code>Red/System [ File: %testlib.reds ] inc: func [n [integer!] return: [integer!]][n + 1] #export [inc] </code></pre> <p>You compile such shared library using the new -dlib command-line option:</p> <blockquote> <blockquote> <p>do/args %rsc.r "-dlib testlib.reds"</p> </blockquote> </blockquote> <p>The output binary name will have a platform-specifc suffix (.dll, .so or .dylib).</p> </blockquote> <p>Secondly, I was finally able to get a single simple <strong>Red</strong> script to compile to a .dll. The <a href="http://static.red-lang.org/red-system-specs.html#section-15.9" rel="noreferrer"><code>#export</code></a> directive needs to be in a Red/System context as you can see the <code>#system-global</code> directive provides. Any function you have in Red needs to be wrapped with a Red/System wrapper. You can do this using <a href="http://static.red-lang.org/red-system-specs.html#section-15.8" rel="noreferrer"><code>#call</code></a> as done below:</p> <pre><code>Red [] hello: does [print "hello"] #system-global [ hellosystem: does [ #call [hello] ] #export cdecl [hellosystem] ] </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload