Here's an example shared object compilation and use from j version 8. Other examples exist at rosettacode.org. On the Tasks page search for "call". If, on the other hand you want to embed j in another language this is also solved at rosettacode.
http://rosettacode.org/wiki/Use_another_language_to_call_a_function#J


/*

  on linux system this file is  ./c.c

  COMPILATION

  $ gcc -c -fPIC c.c
$ gcc -shared -Wl,-soname,libmylittledemo.so.1 -o libmylittledemo.so.1.0.1 c.o


  USE IN J VERSION 8

  $ J8
     boxdraw_j_ 1
     './libmylittledemo.so.1.0.1 hi n' 15!:0 ''
  world
  +-+
  |0|
  +-+

*/


void hi(void) {
  int puts(const char*);
  puts("world");
}

Date: Wed, 9 Jul 2014 21:14:53 +0900
From: Jon Hough<[email protected]>
To:<[email protected]>
Subject: Re: [Jprogramming] DLL Lab
Message-ID:<[email protected]>
Content-Type: text/plain; charset="utf-8"

Thanks for replying,

I understand .cpp indicates a c++ file. What I wanted to do was follow the lab 
that used this file, which seems to not exist.
I see your point about needing a compiler, but I assumed there was a way to 
make a dll using J and perhaps the microsoft compiler (on windows, linux and 
mac already have gcc inbuilt).
The next best thing is to link to the j.dll which I assume calls my script in 
turn. But again, the lab seems to be geared toward J6, which I unceremoniously 
deleted.

Having said that, I am pretty sure I read somehwere on the J wiki that it is 
possible to build an executable file, so J does not need to be installed on the 
computer. Can't find it now though.


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to