Unix - Linking newLISP source and executable - newbie query

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
BDunbar
Posts: 8
Joined: Fri Feb 17, 2012 7:46 pm

Unix - Linking newLISP source and executable - newbie query

Post by BDunbar »

New to NewLISP. Also new to writing code that needs to be compiled and linked [1]

From the manual, '23. Linking newLISP source and executable" I find that to compile/link I need a copy of link.lsp and newlisp in the same directory. Experimenting, I see symbolic links will serve the same purpose.

Now, before I hack up a bash script to create symbolic links in any given directory I want to compile in .. is there a better way to get 'link.lsp' and newlisp to the directory where the code is? An already existing script?

~brian

[1] Last time I did anything like compiling and linking [2] was with Clipper Summer of '87, in 1991. Which was an extension language for dBase III. So we're talking a super-long time ago.

[2] Not counting using gcc to compile and etc another's code.

jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Re: Unix - Linking newLISP source and executable - newbie qu

Post by jopython »

Can you try this?

Code: Select all

newlisp /path/to/link.lsp
(link "newlisp" "your-exe-name" "your_newlisp_script.lsp")

BDunbar
Posts: 8
Joined: Fri Feb 17, 2012 7:46 pm

Re: Unix - Linking newLISP source and executable - newbie qu

Post by BDunbar »

Code: Select all

$ ls
uppercase.lsp
$ newlisp /usr/share/newlisp/util/link.lsp
newLISP v.10.3.3 on OSX IPv4/6 UTF-8, execute 'newlisp -h' for more info.

> (link "newlisp" "uppercase" "uppercase.lsp")
original newlisp executable:newlisp
new executable:uppercase
source:uppercase.lsp

ERR: array, list or string expected : (file-info orgExe)
called from user defined function link

BDunbar
Posts: 8
Joined: Fri Feb 17, 2012 7:46 pm

Re: Unix - Linking newLISP source and executable - newbie qu

Post by BDunbar »

I lifted uppercase.lsp from the docs - but I don't think it's the problem?

Code: Select all

$  cat uppercase.lsp
:: uppercase.lsp - Link example
(println (upper-case (main-args 1)))
(exit)
$

jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Re: Unix - Linking newLISP source and executable - newbie qu

Post by jopython »

Hmm, I don't remember seeing the error before.
However can you add the pathname for the newlisp executable in your repl.

Code: Select all

newlisp /path/to/link.lsp
(link "/path/to/newlisp executable" "uppercase" "uppercase.lsp")
If that fails too, you may copy the newlisp executable to your script path.
Cheers!

BDunbar
Posts: 8
Joined: Fri Feb 17, 2012 7:46 pm

Re: Unix - Linking newLISP source and executable - newbie qu

Post by BDunbar »

Hmm, I don't remember seeing the error before.
OS X 10.6.8
Installed using the package

Nothing out of the ordinary about the system or what I've done to it, that I can think of.
However can you add the pathname for the newlisp executable in your repl.
So I can!

Code: Select all

$ cat uppercase.lsp
:: uppercase.lsp - Link example
(println (upper-case (main-args 1)))
(exit)
$ which newlisp
/usr/bin/newlisp
$ newlisp /usr/share/newlisp/util/link.lsp
newLISP v.10.3.3 on OSX IPv4/6 UTF-8, execute 'newlisp -h' for more info.

> (link "/usr/bin/newlisp" "uppercase" "uppercase.lsp")
original newlisp executable:/usr/bin/newlisp
new executable:uppercase
source:uppercase.lsp
true
> (exit)
$ chmod +x uppercase
$ ./uppercase foo
FOO
$
Doing it the above way is probably 'newlisp-ier' and more optimal given that I'm trying to _learn_ something. I already know how to make bash scripts.

Locked