Create an executable for a program in an interpreted language: Difference between revisions
Create an executable for a program in an interpreted language (view source)
Revision as of 04:34, 11 July 2022
, 1 year ago→{{header|J}}
m (→{{header|J}}: it's jedo() nowadays) |
|||
Line 363:
Meanwhile, we could do something similar with compiled C. We have the option of feeding the text to the jconsole executable, or we could do what the [https://github.com/jsoftware/jsource/blob/master/jsrc/jconsole.c#L313 jconsole] executable does and link to the J shared library, calling jedo() to run our script.
That said, if you have your heart set on creating an executable of your own, here's a minimal example which builds and runs under Linux:
<lang C>/* github jsoftware/jsource 903-release-b */
/* link with -ldl */
#include <dlfcn.h>
#include "j.h"
#include "jeload.h"
int main() {
void* jdll= dlopen("./libj.so", RTLD_LAZY);
JST* jt= ((JInitType)dlsym(jdll, "JInit"))();
JDoType jdo= dlsym(jdll,"JDo");
jdo(jt, (C*)"('Hello, World!',10{a.) 1!:2<'/proc/self/fd/1'");
exit(0);
}</lang>
=={{header|Phix}}==
|