Compile during runtime

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
User avatar
SebMcClouth
Veteran
Posts: 240
Joined: Fri Apr 29, 2005 2:20 am
Location: Inside the Matrix

Compile during runtime

Post by SebMcClouth »

Heheheh... yes I need to perform this action...

I'll draw the scene for ya:

I'm running my code which could be installing another program...
Now I want my program to able to compile a program (.bas) as well as a library. How can I achieve this if I have the needed qb-files along with it?

BTW You could intreprete this also as the following question: How can I achieve a commandline compile??

grtz

Seb
I know why you're here. I know what you've been doing... why you hardly sleep, why you live alone, and why night after night, you sit by your computer...<br>
Unfortunately, no one can be told what Qbinux is. You have to see it for yourself.
Antoni
Veteran
Posts: 132
Joined: Wed Jun 15, 2005 3:01 pm
Contact:

Post by Antoni »

Code: Select all

bc myfile.bas,,;
link myfile.obj,,,path_to_bcom45.lib;
both BC.EXE and LINK.EXE are in the QB directory.

You have a complete description of QB's command line at
http://qbcm.hybd.net/issues/1-9/#btau
User avatar
SebMcClouth
Veteran
Posts: 240
Joined: Fri Apr 29, 2005 2:20 am
Location: Inside the Matrix

Post by SebMcClouth »

That's all??

grtz
Seb
I know why you're here. I know what you've been doing... why you hardly sleep, why you live alone, and why night after night, you sit by your computer...<br>
Unfortunately, no one can be told what Qbinux is. You have to see it for yourself.
Antoni
Veteran
Posts: 132
Joined: Wed Jun 15, 2005 3:01 pm
Contact:

Post by Antoni »

Let me correct it..

Code: Select all

bc /o myfile.bas,,;
link myfile.obj,,,path_to_bcom45.lib;
Yes, that's all for a simple source, not using ON ERROR or "ON anything",and not using external libraries.

At the end you will have to delete a myfile.obj, myfile.map, and myfile.lst.
User avatar
SebMcClouth
Veteran
Posts: 240
Joined: Fri Apr 29, 2005 2:20 am
Location: Inside the Matrix

Post by SebMcClouth »

What if I have to compile a file that needs a library... for example:

Code: Select all

'$include:'sumfin.bi'
grtz?
I know why you're here. I know what you've been doing... why you hardly sleep, why you live alone, and why night after night, you sit by your computer...<br>
Unfortunately, no one can be told what Qbinux is. You have to see it for yourself.
Antoni
Veteran
Posts: 132
Joined: Wed Jun 15, 2005 3:01 pm
Contact:

Post by Antoni »

Does it mean you have a sumfin.lib to link?

in that case it wuld be:

Code: Select all

bc /o myfile.bas,,;
link myfile.obj,,,path_to_bcom45.lib sumfin.lib ; 
User avatar
SebMcClouth
Veteran
Posts: 240
Joined: Fri Apr 29, 2005 2:20 am
Location: Inside the Matrix

Post by SebMcClouth »

Ah okay thx...

Can I compile it like this:

Code: Select all

shell "bc /o myfile.bas,,;"
shell "link myfile.obj,,,path_to_bcom45.lib sumfin.lib ;"
Grtz

Seb
I know why you're here. I know what you've been doing... why you hardly sleep, why you live alone, and why night after night, you sit by your computer...<br>
Unfortunately, no one can be told what Qbinux is. You have to see it for yourself.
Antoni
Veteran
Posts: 132
Joined: Wed Jun 15, 2005 3:01 pm
Contact:

Post by Antoni »

Yes, it should work.
Try it first keying in the commands from a dos prompt, as you may have to specify paths.
mennonite

having never tried it...

Post by mennonite »

i figured it was at least that simple...

i don't understand though, what difference would On Error make, and what would you do then? erm, whats the most complicated command you would need to compile a single module with a single included library?
Guest

Post by Guest »

Code: Select all

 
::bc program [/options] [, object] [, listfile] [;]
:: /a    include asm in the list file   
:: /ah   huge arrays  
:: /c### comms receive buffer size
:: /d    debug check ctrl_brk + int overflow + array bound + check gosub/return    
:: /e    on error`+ resume number
:: /mbf
:: /o    standalone
:: /r    arrays last index first
:: /s    fast strings
:: /t    terse 
:: /v    check emulated events ON... on every statement
:: /w    check emulated events ON... on every numbered line
:: /x    RESUME, RESUME NEXT, RESUME 0
:: /zd   add line info for use with Symbdeb
:: /zi   add line info for use with codeview  
::  ;    don't ask for missing params
and for link

Code: Select all

::link [/options] objfile [objfile] [libfile.lib], [exefile], [mapfile],  [libfile] [libfile] [;]
:: /BATCH                         /BINARY
:: /CODEVIEW                      /CPARMAXALLOC
:: /DOSSEG                        /DSALLOCATE
:: /EXEPACK                       /FARCALLTRANSLATION
:: /HELP                          /HIGH
:: /INFORMATION                   /LINENUMBERS
:: /MAP                           /NODEFAULTLIBRARYSEARCH
:: /NOEXTDICTIONARY               /NOFARCALLTRANSLATION
:: /NOGROUPASSOCIATION            /NOIGNORECASE
:: /NOPACKCODE                    /OVERLAYINTERRUPT
:: /PACKCODE                      /PACKDATA
:: /PAUSE                         /QUICKLIBRARY
:: /SEGMENTS                      /STACK
Normally all of this is dealt with by the IDE...

The link in my previous post details every option (and some more that a pplies to PDS)
mennonite

holy crap!

Post by mennonite »

if it weren't for the ide, you might as well be compiling c code! who knew it was so complex!?
User avatar
SebMcClouth
Veteran
Posts: 240
Joined: Fri Apr 29, 2005 2:20 am
Location: Inside the Matrix

Post by SebMcClouth »

How I compile it like the ide does??

grtz
Seb
I know why you're here. I know what you've been doing... why you hardly sleep, why you live alone, and why night after night, you sit by your computer...<br>
Unfortunately, no one can be told what Qbinux is. You have to see it for yourself.
Guest

Post by Guest »

I see no point in "compiling like the ide" as far as the method you have works.

The ide does a lot of things in the background:

-It preprocesses the sources: you can have it to compile things with '$include:' files in places specified in the "Options>Directories" menu. If you compile from command line you must edit the source and specify the include dir there, you can't do it in the command line.

-It parses the source to find if the switches /e, /x, /v or /w apply and sets them automatically. It's not smart enough to specify /ah or /l, you must specify those when calling the IDE.

-The linker uses the /batch option and have every other parameter set in a command file file that's erased at the end of linking. If you break somehow a linkage you will be able to check it it.
Seb McClouth

Post by Seb McClouth »

I found some code in the ABC packets which seems helpfull, let's hope it works... else I'd be posting here again, but thx for the help!!

grtz
Seb
Post Reply