Author Topic: Scriptbasic Build Linux  (Read 62457 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #240 on: June 25, 2019, 05:31:17 PM »
My next task is try to create a standalone environment where libscriba.so and any extension modules used would be configured when the script executable runs. The first function would be to configure itself. Dependencies are assumed to be already installed.

I'm also looking at using SQLite to store lines of BASIC code and SB could generate threads dynamically from the multi--line string that would be built.
« Last Edit: June 25, 2019, 05:37:23 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #241 on: June 25, 2019, 06:55:06 PM »
Compiled scripts using a shared object interpreter really runs sweet.

Try the -Eo option and you will see there isn't a difference in size with your model.

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #242 on: June 25, 2019, 07:39:30 PM »
You decide.

Create standalone executable.

Code: ScriptBasic
  1. PRINT "Hello World!\n"

-Co

pi@RPi3B:~/sbrt/2c $ scriba -Co hello.c hello.sb
pi@RPi3B:~/sbrt/2c $ gcc -Os hello.c -L/home/pi/sbrt/lib -l:libscriba.a -ldl -lm -lpthread -o hello
pi@RPi3B:~/sbrt/2c $ ./hello
Hello World!
pi@RPi3B:~/sbrt/2c $ ls -l hello
-rwxr-xr-x 1 pi pi 606872 Jun 25 19:30 hello
pi@RPi3B:~/sbrt/2c $



-Eo

pi@RPi3B:~/sbrt/2c $ /home/pi/sbrt/bin/scriba -Eo ezhello hello.sb
pi@RPi3B:~/sbrt/2c $ chmod 755 ezhello
pi@RPi3B:~/sbrt/2c $ ./ezhello
Hello World!
pi@RPi3B:~/sbrt/2c $ ls -l ezhello
-rwxr-xr-x 1 pi pi 637298 Jun 25 19:33 ezhello
pi@RPi3B:~/sbrt/2c $


I'm unable to compile using libscriba.so on the RPi 3 B.


pi@RPi3B:~/sbrt/2c $ gcc -Os hello.c -L/home/pi/sbrt/lib -lsb ./libscriba.so -ldl -lm -lpthread -o hello
/usr/bin/ld: hello: hidden symbol `__aeabi_idivmod' in /usr/lib/gcc/arm-linux-gnueabihf/6/libgcc.a(_divsi3.o) is referenced by DSO
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
pi@RPi3B:~/sbrt/2c $
« Last Edit: June 25, 2019, 08:20:04 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #243 on: June 25, 2019, 08:35:40 PM »
This fixed it.


pi@RPi3B:~/sbrt/2c $ gcc -Os hello.c -lsb /home/pi/sbrt/lib/libscriba.so -ldl -lm -lpthread -lgcc_s -o hello
pi@RPi3B:~/sbrt/2c $ ./hello
Hello World!
pi@RPi3B:~/sbrt/2c $ ls -l hello
-rwxr-xr-x 1 pi pi 27896 Jun 25 20:39 hello
pi@RPi3B:~/sbrt/2c $


It seems all is needed is stndlone.o


ar rcs /home/pi/sbrt/lib/libsb2.a stndlone.o

pi@RPi3B:~/sbrt/2c $ gcc -Os hello.c -L/home/pi/sbrt/lib -lsb2 /home/pi/sbrt/lib/libscriba.so -ldl -lm -lpthread -lgcc_s -o hello2
pi@RPi3B:~/sbrt/2c $ ./hello2
Hello World!
pi@RPi3B:~/sbrt/2c $ ls -l hello2
-rwxr-xr-x 1 pi pi 13528 Jun 25 21:18 hello2
pi@RPi3B:~/sbrt/2c $


This is as trim as I can get it.


pi@RPi3B:~/sbrt/2c $ gcc -Os hello.c ./stndlone.o ./libscriba.so -ldl -lm -lpthread -lgcc_s -o hello3
pi@RPi3B:~/sbrt/2c $ ./hello3
Hello World!
pi@RPi3B:~/sbrt/2c $ ls -l hello3
-rwxr-xr-x 1 pi pi 13528 Jun 25 22:20 hello3
pi@RPi3B:~/sbrt/2c $



Looking at the make file for libscriba.so it seemed there was duplication in libraries. This works.


jrs@jrs-laptop:~/sb/2c$ gcc -Os testfor.c ./stndlone.o ./libscriba.so -o testfor
jrs@jrs-laptop:~/sb/2c$ ./testfor
-5
-4
-3
-2
-1
0
1
2
3
4
5
jrs@jrs-laptop:~/sb/2c$ ls -l testfor
-rwxr-xr-x 1 jrs jrs 18104 Jun 26 00:19 testfor
jrs@jrs-laptop:~/sb/2c$

« Last Edit: June 26, 2019, 12:22:17 AM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #244 on: June 26, 2019, 07:09:17 PM »
AIR,

Here is my concept for the standalone SB app.

* Scripts will be compiled and use libscriba.so which would be in the app home directory.

* I would create a precompiled basic.conf that points to the current directory (./) for modules location. The compiled script already has any INCLUDE/IMPORT code in compiled binary form.

* I would do a SYSTEM command as one the first steps to set the SCRIBACONFIG environmental variable to SB's CURDIR() location.

Extension modules might be loaded prior to the script running so my idea of setting SCRIBACONFIG dynamically at runtime may not be possible.

Your thoughts.


Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #245 on: June 26, 2019, 10:45:26 PM »
This looks to have gotten a whole lot simpler. The compiled script is finding the needed extension module (.so) without using a basic.conf as long as the module resides in the same directory as the executable. Both the dht11.sb and wpi.bas include file are compiled together as dht11.

Code: ScriptBasic
  1. IMPORT wpi.bas
  2.  
  3. samples = WPI::DHT11(7,humidity,temperature)
  4. PRINT FORMAT("[%d] %.1f %%  %.1f C\n",samples,humidity,temperature)
  5.  


pi@RPi3B:~/sbrt/2c $ ./dht11
[1] 58.0 %  22.8 C
pi@RPi3B:~/sbrt/2c $ scriba
bash: scriba: command not found
pi@RPi3B:~/sbrt/2c $ ls -l dht11
-rwxr-xr-x 1 pi pi 33104 Jun 26 22:37 dht11
pi@RPi3B:~/sbrt/2c $
« Last Edit: June 26, 2019, 10:50:47 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #246 on: June 27, 2019, 10:40:58 AM »
AIR,

I propose we add -lgcc_s to the the SB make_gcc definition file for ARM. I can't compile a standalone script without it.

Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: Scriptbasic Build Linux
« Reply #247 on: June 27, 2019, 01:36:36 PM »
AIR,

I propose we add -lgcc_s to the the SB make_gcc definition file for ARM. I can't compile a standalone script without it.

How will this help you, if you still need to invoke the compilation for standalone manually?

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #248 on: June 27, 2019, 02:11:27 PM »
If libgcc_s.a gets rolled into libscriba.so I won't have to add it anymore.

I'm looking at maybe modifying stndlone.c to be a little more flexible with the configuration file loading.
« Last Edit: June 27, 2019, 02:29:04 PM by John »

Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: Scriptbasic Build Linux
« Reply #249 on: June 27, 2019, 02:58:46 PM »
Have you tested this idea?

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #250 on: June 27, 2019, 03:02:43 PM »
In the process but wanted your take first.

As ot looks now, these are the standalone requirements needed for your set of compiled script files.

Runtime
libscriba.so
Any extension module shared objects

Compiling
stndlone.c
libgcc_s.a if on ARM - may be able to roll this into libscriba.so.
« Last Edit: June 27, 2019, 03:49:08 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #251 on: June 27, 2019, 04:36:04 PM »
It didn't work so -lgcc_s is a standalone compile requirement on ARM.

sdbg needs a dummy include file generated like dbg or the final compile will show an error for the include. (preprocessors don't have include files)


starting compilation
ar: creating /home/pi/sb-dev/bin/lib/lscriba.a
ScriptBasic v2.1
Variation >>STANDARD<< build 1
Magic value 859036471
Node size is 24
Extension interface version is 11
Compilation: Jun 27 2019 16:43:24
mkdir: cannot create directory ‘/home/pi/sb-dev/bin/var/httpd’: File exists
ar: creating /home/pi/sb-dev/bin/lib/libscriba.a
scriba executable OK 
sbhttpd executable OK 
libscriba library OK 
MODULE curl:     dll OK   lib OK   bas OK 
MODULE mt:       dll OK   lib OK   bas OK 
MODULE sqlite:   dll OK   lib OK   bas OK 
MODULE curses:   dll OK   lib OK   bas OK 
MODULE sdbg:     dll OK   lib OK   bas FAIL
MODULE mysql:    dll OK   lib OK   bas OK 
MODULE dbg:      dll OK   lib OK   bas OK 
MODULE json:     dll OK   lib OK   bas OK 
MODULE ip:       dll OK   lib OK   bas OK 
MODULE ux:       dll OK   lib OK   bas OK 
MODULE mxml:     dll OK   lib OK   bas OK 
MODULE slre:     dll OK   lib OK   bas OK 
MODULE hash:     dll OK   lib OK   bas OK 
MODULE zlib:     dll OK   lib OK   bas OK 
MODULE sbt:      dll OK   lib OK   bas OK 
MODULE trial:    dll OK   lib OK   bas OK 
MODULE odbc:     dll OK   lib OK   bas OK 
MODULE gmp2:     dll OK   lib OK   bas OK 
MODULE cgi:      dll OK   lib OK   bas OK 
MODULE t:        dll OK   lib OK   bas OK 
pi@RPi3B:~/sb-dev $


« Last Edit: June 27, 2019, 05:05:43 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #252 on: October 04, 2019, 10:59:22 AM »
Hi AIR,

It seems iodbc isn't supported on Ubuntu 19.04.

Is there a workaround?

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #253 on: October 05, 2019, 04:34:01 PM »
AIR,

I installed unixodbc-dev and did a make -B on the extension module and it compiled. I haven't tested it yet but this is a good sign.


ubuntu@ubuntu:~/sb-dev-master/extensions/odbc$ make -B
gcc -w -DSTATIC_LINK=1 -c -fpic -fsigned-char -o /home/ubuntu/sb-dev-master/bin/mod/obj/odbc/s_interface.o interface.c -I/usr/include/iodbc
ar -r /home/ubuntu/sb-dev-master/bin/mod/lib/odbc.a /home/ubuntu/sb-dev-master/bin/mod/obj/odbc/s_interface.o 
gcc -w -c -fpic -fsigned-char -o /home/ubuntu/sb-dev-master/bin/mod/obj/odbc/interface.o interface.c -I/usr/include/iodbc
ld -shared -o /home/ubuntu/sb-dev-master/bin/mod/dll/odbc.so /home/ubuntu/sb-dev-master/bin/mod/obj/odbc/interface.o -lodbc
perl /home/ubuntu/sb-dev-master/jamal.pl manual.texi.jam /home/ubuntu/sb-dev-master/bin/texi/mod_odbc.texi
perl /home/ubuntu/sb-dev-master/t2h.pl /home/ubuntu/sb-dev-master/bin/texi/mod_odbc.texi
ubuntu@ubuntu:~/sb-dev-master/extensions/odbc$


Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #254 on: January 19, 2020, 05:42:07 AM »
AIR,

There seems to be a problem with your SQLite SB extension module. The column data is being duplicated in columns that should be null. If I do the select in the SQLite3 CLI, it displays the data correctly.