0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

軽量JavaScriptエンジン “QuickJS” を試す (2021-04-16)

Posted at

qiita:C/C++に組み込める軽量JavaScriptエンジン “QuickJS” を試す」を追体験する。
(環境は Windows10 pro + docker desktop からの Debian busterである)

https://bellard.org/quickjs/

C:\> docker run -it debian:latest

root@2afe0cfe2c13:~# apt-get update
root@2afe0cfe2c13:~# apt-get install gcc git
root@2afe0cfe2c13:~# git clone https://github.com/bellard/quickjs.git
root@2afe0cfe2c13:~# cd quickjs
root@2afe0cfe2c13:~/quickjs# make install
root@2afe0cfe2c13:~/quickjs# ls -la $(which qjs)
956 -rwxr-xr-x 1 root root 978248 Apr 16 10:04 /usr/local/bin/qjs

小さい。かわいい。

続いて [JS ファイルをコンパイルする](JS ファイルをコンパイルする) を試す。

root@2afe0cfe2c13:~# ls -la a.out
-rwxr-xr-x 1 root root 5478048 Apr 16 10:31 a.out
root@2afe0cfe2c13:~# strip a.out
root@2afe0cfe2c13:~# ls -la a.out
-rwxr-xr-x 1 root root 888104 Apr 16 10:33 a.out
root@2afe0cfe2c13:~# ./a.out
Hello, Alice!

興味があるのは、これポータビリティあるかどうかということ。
もう一個、まっさらなdebian:latest を起動してコピーして実行してみた。動くじゃないか!!

root@87bbb47e078a:~# ./a.out
Hello, Alice!
root@87bbb47e078a:~# qjs
bash: qjs: command not found

これは面白そう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?