blitzCC problem

Blitz3D Forums/Blitz3D Programming/blitzCC problem

hi!

i tried to make a simple compiler using the blitzCC compiler.
when you run compiler.bb, the blitzcc will compile and run test.bb
when you compile the compiler.bb to an exe and run that, it won't compile the test program anymore!?
is there a solution?

thank you.

compiler.bb
blitzcc$ = "D:\Programme\Blitz3D"

CompileToExe("program.bb", blitzcc$)

Function CompileToExe(path$, blitzcc$)
blitzcc$ = Replace(blitzcc$, "/", "")
If Right(blitzcc$, 1) <> "" Then blitzcc$ = blitzcc$ + ""
ExecFile blitzcc$ + "Bin\blitzcc.exe " + Chr(34) + path$ + Chr(34)
End Function


test.bb
Print "Hello world!"
RuntimeError "Hello world!"
End


It works for me when I do it like this:

ExecFile ""+chr(34)+"C:/Program Files/Blitz3D/bin/blitzcc.exe"+chr(34)+" "+chr(34)+"C:/test.bb"+chr(34)+""


I think you need the quotes around the location of the compiler also.

it doesnt work either!
it just quits the compiling proccess...
also i tried it with your method AND i copied the test.bb in the c:\ drive of course!

Do you have the latest Blitz3D?

yes i do.

did you replace the ExecFile line by

print the path
waitkey()

and then visually check what it really does?

yes i did. i also tried a few parameters like -d or -c...
everything is working. but when i compile the compiler.bb, it won't work anymore.

Hmmm. This is a total guess - and someone who knows how the IDE interacts with blitcc.exe might know better - but doesn't the IDE pass the CurrentDir() to blitzcc.exe? If you move file test.bb somewhere safe (so that the IDE no longer 'knows' where to find it [i.e. it's not in your default .bb folder or in the last folder accessed via the file requester]) does compiler.bb still work when run from inside the IDE?

In Ked's example he has explicitly specified "c:/test.bb" and so blitzcc.exe knows where to find the source file.

How are you passing compiler.exe the name of the blitz source file - do you include the full pathname?

I meant with the compiled compiler.bb

So did I!!!

It has to be something that IS being supplied via the IDE, which ISN'T when running the compiled version. If the IDE is passing the relevant path (for "test.bb") to blitzcc.exe then compiler.bb will work. However, this will not happen when you run the compiled version - hence you will need to supply the source-file's directory, or blitzcc.exe won't know where to find "test.bb".

I'm suggesting that Ked's example worked because he included "c:/" in the filename (I assume you're hard-coding the name of the file to be compiled?) before he compiled compiler.bb. Then when he ran compiler.exe, it passed "c:/test.bb" rather than "test.bb" to blitzcc.exe.

Are you including the full directory name, or just specifying "test.bb"?

Of course I could be barking up completely the wrong tree...

i ceartainly did try to use the path c:\test.bb
also i tried it with your method AND i copied the test.bb in the c:\ drive of course!


hmh. if you run compiler.bb it works perfect, but if you compile the compiler.bb file and run compiler.exe, it just wont run the test.bb file anymore. thats what panics me...

Hmmm. When you say "it works perfect" - what do you mean? I'm asking because I just ran your code via the IDE (having first created "test.bb") and it simply ran before saying "Program has ended".

On your system when you run compiler.bb via the IDE is source file "test.bb" compiled into program "test.exe"? Coz on my system it wasn't...

you´re right, it´s spooky...

chalky - no, it´s executing test.bb. To create an exe you´d need to -o parameter.

Aah - I see - it was the name of the function that threw me there - hehe!!! Hmmm - well "test.bb" wasn't executed either!

[edit]
Ok - got this to work via IDE and compiled EXE [by surrounding whole command line parm with chr$(34)'s and adding "(" and ")" to ExecFile command]:
blitzcc$ = "C:/Program Files/Blitz3D/"

CompileToExe("test.bb", blitzcc$)
End

Function CompileToExe(path$, blitzcc$)
	blitzcc$ = Replace(blitzcc$, "/", "")
	If Right(blitzcc$, 1) <> "" Then blitzcc$ = blitzcc$ + ""

	blitzcc$=Chr$(34)+blitzcc$+"Bin\blitzcc.exe " + Chr(34) + path$ + Chr(34)+Chr$(34)
	ExecFile(blitzcc$)
End Function

HOWEVER - nothing is displayed even though compilation is now taking place. Or I THINK it is...

On your system when you run compiler.bb via the IDE is source file "test.bb" compiled into program "test.exe"? Coz on my system it wasn't...
no, this compiler.bb code compiles the program directly into RAM

hm. someone like mark or skidracer should be looking at this right now! i know they are... a topic like "blitzCC problem" can't be overseen by them
so... what do you say?

Hurrah - I have duplicated [and fixed] your problem at last! Since blitzcc.exe was evidently failing when called outside the IDE, I tried executing blitzcc.exe via a command line window, and got the following error msg:

"Can't find blitzpath environment variable"

I therefore created an environment variable called "blitzpath" with a value of "c:\program files\blitz3d\" (my blitz3d.exe path) and compiler.exe compiled and executed "test.bb" as if it had been done via the IDE!

Now - if I'd only read the instructions in file "versions.txt" - I could have solved that several hours ago... :o/

I was doing research about this and found this information:


-h : Show Help
-q : Operate quietly
+q : Operate very quietly
-d : Compile and run in debug mode
-k : Print a list of all keywords
+k : Print a list of all keywords and quickhelp
-o exefile$ : Create an executable with the name/location inside the exefile$ string



EXAMPLE: "blitzcc.exe" "test.bb"
EXAMPLE: "C:/Program Files/Blitz3D/bin/blitzcc.exe" -o "testexe.exe" "test.bb"

So in Blitz it shoud look like:
ExecFile(chr$(34)+"C:/Program Files/Blitz3D/bin/blitzcc.exe"+chr$(34)+" "+chr$(34)+"C:/test.bb"+chr$(34))


By the way,
blitzcc$ = "C:\Program Files\Blitz3D"

CompileToExe("test.bb", blitzcc$)
End

Function CompileToExe(path$, blitzcc$)
	blitzcc$ = Replace(blitzcc$, "/", "")
	If Right(blitzcc$, 1) <> "" Then blitzcc$ = blitzcc$ + ""

	blitzcc$=Chr$(34)+blitzcc$+"Bin\blitzcc.exe "+Chr(34)+"-o test.exe "+path$+Chr(34)+Chr$(34)

	ExecFile(blitzcc$)
End Function


The blitzcc$ string needs to be global or it will open up the folder the BB is running from. I found that out.

EDIT: Information source: http://www.bettiesart.com/tc/ultrablitz/

Hi Ked,

blitzcc$ does not need to be global since it is being passed to the function as a parameter. You also only need to enclose the command line arguments with chr$(34) (and sometimes the whole command line - as you said in an earlier post) if either contains spaces, since blitzcc.exe expects spaces to be delimiters. Having created the env variable the code I posted above now works correctly.

Devils problem is probably due to him not having the environment variable set up on his system.

hey, the environment variable is the final solution!
it works perfectly without any bugs at all!
thank you guys! :)

btw: it is 5 AM here. didnt know you were so active while i should be sleeping... ;D