Author Topic: ? about compiling C code produced with ScriptBasic  (Read 19561 times)

GSAC3

  • Newbie
  • *
  • Posts: 23
? about compiling C code produced with ScriptBasic
« on: September 29, 2014, 11:44:15 AM »
SUPPORT:

I want to produce a WINDOWS compatible EXE file from a C code file produced with either SCRIBA 22b2 or 3.0.

Where can I find the correct set of compile and link command lines and correct LIB files to do this with either the Borland, MinGW32, or Pelles C compilers?

Based on the current development status, which version of ScriptBasic would be the best to use for this purpose?
 
Don

support

  • Administrator
  • *****
  • Posts: 859
    • Script BASIC Open Source Project
Re: ? about compiling C code produced with ScriptBasic
« Reply #1 on: September 29, 2014, 12:26:49 PM »
Hi Don,

Please use the Script BASIC 2.2 beta release for all your development. (see download board - sticky post) When using the scriba -Co new.c your.bas to create the C wrapper for the binary PCODE SB script, you are using libscriba.dll for your runtime support. This option creates small footprint executables sharing a common runtime. Send me an e-mail to support@scriptbasic.org and I will send you the latest source. You could use the 2.2 binaries and the 2.1 source (headers) as that is the only thing needed for the source and nothing has change in 2.2 with headers. I posted on the forum an example of compiling to C SB scripts. If you need further help, just ask.

As an alternative, you can create a standalone .exe of your script with the scriba -Eo new.exe your.bas . This option appends your binary tokenized script to the end of scriba.exe and renames it to the name given. Scriba always checks for an appended script before processing any of its command line options.

John
« Last Edit: September 29, 2014, 04:00:30 PM by support »
Script BASIC Project Manager

GSAC3

  • Newbie
  • *
  • Posts: 23
Re: ? about compiling C code produced with ScriptBasic
« Reply #2 on: September 30, 2014, 11:12:48 AM »
John:

Thanks for your reply.

I wanted to try your "small footprint" EXE approach, but after looking at your SB2C post to see how it is done for WINDOWS, I am thoroughly confused.  Your example seems to be for a system running LINUX whch I am totally unfamiliar with.

In your example you reference a "libscriba" which I can't fine anywhere in the SB22b2 distribution.  Neither can I locate the "ibscriba.dll" you mentioned in your reply to my original message.

Can you please clarify?

Don
 

support

  • Administrator
  • *****
  • Posts: 859
    • Script BASIC Open Source Project
Re: ? about compiling C code produced with ScriptBasic
« Reply #3 on: September 30, 2014, 06:27:57 PM »
Don,

I'm still in the process of rebuilding my Linux system after it got trashed by a bad install script from a 3rd party library. Here is steps to compile a Script BASIC script to C under Ubuntu 14.04.1 LTS 64 bit. As soon as I get my XP virtualBox restored I post the Windows version of this.

Code: [Select]
jrs@laptop:~/sb/sb22/test$ cat testlike.sb
t = "Text at the beginning <tag>OPEN</tag>just some text<tag>CLOSE</tag> text at the end"

IF t LIKE "*<tag>*</tag>*<tag>*</tag>*" THEN
PRINT JOKER(2),"\n"
PRINT JOKER(3),"\n"
PRINT JOKER(4),"\n"
ELSE
PRINT "No Match\n"
END IF


jrs@laptop:~/sb/sb22/test$ scriba -Co testlike.c testlike.sb
jrs@laptop:~/sb/sb22/test$ gcc -Os testlike.c -I /home/jrs/sb/scriptbasic/source /usr/lib/sb.a -lscriba -lm -lpthread -ldl -o testlike
jrs@laptop:~/sb/sb22/test$ ls -l testlike*
-rwxrwxr-x 1 jrs jrs 25813 Sep 30 18:23 testlike
-rw-rw-r-- 1 jrs jrs  8225 Sep 30 18:23 testlike.c
-rw------- 1 jrs jrs   233 Sep 24 11:06 testlike.sb
jrs@laptop:~/sb/sb22/test$ ./testlike
OPEN
just some text
CLOSE
jrs@laptop:~/sb/sb22/test$ file testlike
testlike: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=d0837f48122526833ddab760f8bdec3199efe4b9, not stripped
jrs@laptop:~/sb/sb22/test$
« Last Edit: October 01, 2014, 01:12:55 AM by support »
Script BASIC Project Manager

support

  • Administrator
  • *****
  • Posts: 859
    • Script BASIC Open Source Project
Re: ? about compiling C code produced with ScriptBasic
« Reply #4 on: October 01, 2014, 12:19:25 PM »
Don,

Just received your e-mail. If you would like the current 2.2 source then download Dave's COM extension module, IDE/Debugger. The following is how to build the sb.a for use with the standalone method of compiling to C.

Code: [Select]
ar rcs sb.a stndlone.obj report.obj myalloc.obj errcodes.obj dynlolib.obj

FYI: Using this method allows you to static link your extension modules used for a more seamless end result.

Script BASIC Project Manager

GSAC3

  • Newbie
  • *
  • Posts: 23
Re: ? about compiling C code produced with ScriptBasic
« Reply #5 on: October 01, 2014, 01:20:07 PM »
John:

Where can I find "Dave's COM extension module, IDE/Debugger" ?

Don

support

  • Administrator
  • *****
  • Posts: 859
    • Script BASIC Open Source Project
Re: ? about compiling C code produced with ScriptBasic
« Reply #6 on: October 01, 2014, 01:27:56 PM »
The post just before your thread contains the link to the Github project site for Dave's COM ext. module. You can download the complete project in a zip from there. Binaries and Windows install included.

Script BASIC Project Manager

GSAC3

  • Newbie
  • *
  • Posts: 23
Re: ? about compiling C code produced with ScriptBasic
« Reply #7 on: October 01, 2014, 01:42:55 PM »
John:

I just tried to access GITHUB (5 times to be exact) and each time CHROME refuses to connect to GITHUB due to faulty access security from the site to CHROME browser.  I am unable to download from GITHUB.

Any other place I can get the download?

Don

support

  • Administrator
  • *****
  • Posts: 859
    • Script BASIC Open Source Project
Re: ? about compiling C code produced with ScriptBasic
« Reply #8 on: October 01, 2014, 03:08:05 PM »
Here you go.
Script BASIC Project Manager

GSAC3

  • Newbie
  • *
  • Posts: 23
Re: ? about compiling C code produced with ScriptBasic
« Reply #9 on: October 02, 2014, 11:13:29 AM »
John:

Thanks for the download.

I'll tinker with the source and see if I can produce a SB.a file to make the "small footprint" version while you are rebuilding your WINDOWS-XP box.

In the meantime, I have found a way to reduce the size of EXE files produced with the  scriba -Eo G:\SB22B2\bin\OUTPUT.exe  %1 option by 60%.

Don
 

support

  • Administrator
  • *****
  • Posts: 859
    • Script BASIC Open Source Project
Re: ? about compiling C code produced with ScriptBasic
« Reply #10 on: October 02, 2014, 12:37:50 PM »
Quote
In the meantime, I have found a way to reduce the size of EXE files produced with the  scriba -Eo G:\SB22B2\bin\OUTPUT.exe  %1 option by 60%.


Script BASIC is < 600KB stock. Glad you found compression to work for you.

Check out Dave's IDE. Very cool.
Script BASIC Project Manager

GSAC3

  • Newbie
  • *
  • Posts: 23
Re: ? about compiling C code produced with ScriptBasic
« Reply #11 on: October 03, 2014, 10:45:21 AM »
John:

I tried Dave's IDE/Debugger as you suggested.

When I use it to run the testmatn.sb script, the debugger gives the following error message --

"error &H68:  The user function "rad" is used but is not defined."

However, when I run the testmath.sb script outside of the IDE/Debugger, it executes fine without error.

Any idea what's causing this?

Is the IDE/Debugger using an older version of scriba.exe?

Don

support

  • Administrator
  • *****
  • Posts: 859
    • Script BASIC Open Source Project
Re: ? about compiling C code produced with ScriptBasic
« Reply #12 on: October 03, 2014, 11:48:28 AM »
Quote
Is the IDE/Debugger using an older version of scriba.exe?

I sent Dave the SB 2.2 source when about mid way in his project. I thought he updated his SB 2.1 source. Just use the scriba & libscriba.dll from the SB 2.2 beta I posted on the download board. (sticky post)

Thanks for the heads-up!
Script BASIC Project Manager

GSAC3

  • Newbie
  • *
  • Posts: 23
Re: ? about compiling C code produced with ScriptBasic
« Reply #13 on: October 13, 2014, 12:22:59 PM »
John:

I am still struggling to produce the "small footprint" compiled version of SB22b2 using the following command line you posted earlier:

ar rcs sb.a stndlone.obj report.obj myalloc.obj errcodes.obj dynlolib.obj

But I can not find either the stndlone.c and stndlone.h or stndlone.obj anywhere in the posted SB22b2 distribution, or the source you posted on this thread.

The only stndlone files I have seen so far were in the SB30 distribution stuff, and I don't know if they will also work with 22b2.

Do you have a set of OBJ files for stnlone, report, myalloc, errorcodes, and dynlolib for version 22b2 that were compiled with the MinGW 32 bit compiler?

Don

GSAC3

  • Newbie
  • *
  • Posts: 23
Re: ? about compiling C code produced with ScriptBasic
« Reply #14 on: October 13, 2014, 12:37:19 PM »
P.S.

Where can I find thw WINDOWS GCC version of libscriba files?

Don