Script BASIC

Support => General Discussions => Topic started by: GSAC3 on September 29, 2014, 11:44:15 AM

Title: ? about compiling C code produced with ScriptBasic
Post by: GSAC3 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
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: support 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
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: GSAC3 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
 
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: support 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$
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: support 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.

Title: Re: ? about compiling C code produced with ScriptBasic
Post by: GSAC3 on October 01, 2014, 01:20:07 PM
John:

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

Don
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: support 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.

Title: Re: ? about compiling C code produced with ScriptBasic
Post by: GSAC3 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
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: support on October 01, 2014, 03:08:05 PM
Here you go.
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: GSAC3 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
 
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: support 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.
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: GSAC3 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
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: support 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!
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: GSAC3 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
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: GSAC3 on October 13, 2014, 12:37:19 PM
P.S.

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

Don
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: support on October 13, 2014, 02:24:11 PM
You can find the Windows gcc (TDM) version that Armando (AIR) did in the downloads section of the forum.
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: GSAC3 on October 16, 2014, 02:11:58 PM
John:

After searching through nearly all of the forum messages in the DOWNLOAD section, I am unable to find an example of how to produce a "small footprint", standalone EXE using GCC.  The example you provided in your SB2C message thread is for LINIX, not WINDOWS XT.  I have been trying, unsuccessfully, for several days now to produce a WINDOWS version of what you did under LINIX.

If you have your WINDOWS XP box working now, can you provide a clear example for WINDOWS like you did for LINIX?

Don


Don
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: support on October 16, 2014, 05:35:25 PM
This worked for me. I recompiled the current Script BASIC 2.2 source with TDM-GCC-32 and attached a zip with binaries needed to compile to C.  Let me know if you run into any problems.


C:\sb22\test>type 4next.sb
FOR x = 1 to 5
  PRINT x,"\n"
NEXT x

C:\sb22\test>scriba -Co 4next.c 4next.sb
C:\sb22\test>gcc -Os 4next.c -I \sb22\source C:\TDM-GCC-32\lib\sb.a -lscriba -lm -lpthread -lws2_32 -ladvapi32 -o 4next
C:\sb22\test>4next
1
2
3
4
5

C:\sb22\test>dir 4next.*
 Volume in drive C has no label.
 Volume Serial Number is 1415-F200

 Directory of C:\sb22\test

10/16/2014  05:32 PM             2,619 4next.c
10/16/2014  05:32 PM            42,505 4next.exe
10/16/2014  05:25 PM                40 4next.sb
               3 File(s)         45,164 bytes
               0 Dir(s)  67,840,901,120 bytes free

C:\sb22\test>
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: GSAC3 on October 17, 2014, 02:47:49 PM
John:

Thanks for the sample GCC compile setup.

I am having a little trouble with the GCC compile, however.  I put the new BIN and LIB subdirectories in my SB22b2 installation, and when I try my TEST sample using the command line sequence below --

scriba -Co TEST.c TEST.sb

gcc -Os TEST.c -I G:\sb22\source G:\MinGW32\lib\sb.a -lscriba -lm -lpthread
-lws2_32 -ladvapi32 -o TEST

The GCC compile above returns two error messages:

“can’t find –lscriba"  and “can’t find –lpthread”

I know I must be doing something wrong but I don't know what.
Where are or should lscriba and lpthread be located?
I am using MinGW32 version 4.9.1.

Don
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: support on October 17, 2014, 05:57:54 PM
libscriba.a and sb.a go in  your MinGW32 lib directory.

If your Script BASIC bin directory is in your search path, you can put your libscriba.dll in there. You need to point to the Script BASIC source headers with the -I command line argument. Look in the MinGW32 lib directory for a libpthread????.a and adjust your command line with the proper filename.

Make sure you're using the MinGW32 shell or have run the .bat script in a standard shell to setup the environment.
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: GSAC3 on October 19, 2014, 02:09:54 PM
John:

Thanks again for your help.  I have everything located in the correct directories now and everything works fine!

One strange thing I discovered was that the MinGW32 distribution I had installed was missing a copy of the libpthread.a file.  I located a copy of the missing file in another MinGW32 distribution that I had loaded with GFORTRAN so I used it and all seems to be working well.

Thanks again for your help.

Don
Title: Re: ? about compiling C code produced with ScriptBasic
Post by: support on October 19, 2014, 02:20:41 PM
Good to hear Don!

Please keep us in the loop with your Script BASIC adventures.