April 28, 2024, 04:09:58 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Compiling Outside of the IDE

Started by emorgan99, May 08, 2007, 11:37:34 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

emorgan99

Can I compile a Emergence Basic program outside of the IDE? How would that be accomplish?

Thanks

Parker

You need to use each tool separately. First you have to use ebparse, the compiler:
ebparse input output
is the format I believe. If you are compiling only a single file, do this:
ebparse input output /m
and for a debug build, this:
ebparse input output /dDEBUG

Next is nasm. You should read the manual or the nasmw -h output to see exactly how to use it, but I think it's something like this:
nasmw -f win32 -o output.obj input.asm

Last is the linker, which you only need to call once. This one can be problematic because you need to specify the library files in a certain order. Here are a couple snippets from a partner developer topic about doing the same with Aurora (the tools are almost identical except for the language syntax):



For the linker you have to use a response file.  There is a limit on how long a command line can be, depending on the OS.  By using a response file you can have an unlimited number of input files.  A response file is just a text file with each line containing either a group of switches or an object filename.  You tell the linker to use the response file by using an '@' infront of the filename.

aclink @link.fil mydll.dll

A typical response file might look like this (for a DLL in debug mode), paths to the libs directory omitted:

-debug
-stacksize 1048576
-stackcommitsize 32768
-oPE -q -m -p- -base 0x10000000 -entry _dllmain -dll -subsys gui
-o mydll.dll
dllstartup.o
mydll.o
mydll.exp
kernel32.lib
user32.lib
...the rest of the built in import libraries

One important thing to remember is that the linker is a console based application so any paths given to it must be enclosed in quotes if, and only if, it has spaces in the filename.  One of those Microsoft pains...

[printing to the response file]...
fprintf(link,"%s\n",MakeShellPath(strLib + "\\kernel32.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\user32.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\gdi32.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\comdlg32.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\comctl32.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\shell32.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\ole32.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\uuid.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\winspool.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\acommon.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\console.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\fileio.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\gui.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\math.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\strings.lib"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\strlib.o"));
fprintf(link,"%s\n",MakeShellPath(strLib + "\\mathlib.o"));
...add $use libraries here
fprintf(link,"%s\n",MakeShellPath(strLib + "\\crtdll.lib"));
...resource output file here



Making a DLL, EXE, LIB, and OBJ are all different though. For OBJ (no compile option), don't call the linker. For DLL and EXE, the process is similar, except you use different startup files and a couple different switches. For LIB, you have to use ar instead, which is a GNU tool, so you can find its manual in the internet.

Hopefully this helps.

emorgan99