Page 1 of 1

Location of the Executable

Posted: Tue Mar 22, 2005 2:53 am
by akee
When you Compile/Run or Compile/Debug, is there a way to force the executable that is created in the [PB folder]\Compilers (has the name PureBasic#######.exe) to the same folder as the source code other than the "Create an Executable" feature.

If not, sure would like that feature in the next release. 8)

Posted: Tue Mar 22, 2005 1:38 pm
by Kale
This would be very nice. I hate having to put dlls, etc. into the compiler folder to get programs running.

Posted: Tue Mar 22, 2005 1:55 pm
by El_Choni
AFAIK, you can put the dlls in the pb source file folder and they'll work the same.

Posted: Tue Mar 22, 2005 2:34 pm
by helpy
This already Works! But the IDE does not support it!

I checked it with a small example. I created a test.pb in directory C:\TEST:

Code: Select all

Debug "TEST"
MessageRequester("","TEST")
Than I opened the cmd-console:

Code: Select all

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\path to\username>cd \TEST

C:\TEST>D:\path to Compiler\PBCompiler.exe test.pb /DEBUGGER /EXE .\test.exe

******************************************
PureBasic v3.92 - Windows x86
******************************************

Compiling test.pb
Loading external libraries...
Starting compilation...
2 lines processed.
Creating executable.

- Feel the ..PuRe.. Power -

C:\TEST>
AND test.exe was created in the directory test!

Here is a simple batch file (name it i.e. pb_debug.bat):

Code: Select all

@echo off

REM check if a file was given as arguemnt
REM if no file was given ... show the usage
if "%~1"=="" goto :ShowUsage

REM set environment variable PBCompiler
set PBCompiler=Drive:\path to compiler\PBCompiler.exe

REM change to drive, where the pb-file is
%~d1

REM change to directory of the pb-file
cd "%~dp1"

REM compile the file
"%PBCompiler%" "%~nx1" /DEBUGGER /EXE "%~n1.exe"

REM call the exe file
echo.
echo.-------------------------------------------------------------------------------
echo program is running in debug mode ...
"%~n1.exe"
echo program execution stopped ...
echo.-------------------------------------------------------------------------------
echo.

REM pause the execution of the batchfile,
REM so you can check the output of PBCompiler
pause

:REM end the batchfile
goto :EOF


REM usage of batch file
:ShowUsage
echo.
echo Usage: pb_debug.bat <source_file.pb>
echo        pb_debug <source_file.pb>
echo.
pause
goto :EOF
For instance ... put the batch file on the desktop. Than drag-and-drop the file test.pb from the explorer window to the batch file ... it will compile the dropped file to an exe with the same name as the file ... in the same directory

cu, helpy

Posted: Tue Mar 22, 2005 3:20 pm
by El_Choni
Of course the IDE does support it; when you select "create executable" and you're prompted for the exe folder and name, the IDE calls the compiler with the same options you're using in your example.

You can also add those options for the PBCompiler as a new Tool (in the Tools menu), without having to use a .bat file.

Posted: Tue Mar 22, 2005 3:39 pm
by helpy
Hi El_Choni,
El_Choni wrote:Of course the IDE does support it; when you select "create executable" and you're prompted for the exe folder and name, the IDE calls the compiler with the same options you're using in your example.
No! That is not true! I activated debugger in IDE (with menu Compiler->Debugger) than I created the exe and started it. The debugger window does not show up!

Maybe you can explain me how it will work ...
El_Choni wrote:You can also add those options for the PBCompiler as a new Tool (in the Tools menu), without having to use a .bat file.
But in this case I cannot tell the compiler that the exe name should be extracetd from the source-filename (i.e. file.pb => file.exe).

And with [F5] (menu Compiler->Compile/Run) an random exe name is created and the exe file will be located in the compilers directory. If I have some external files which are relative to the exe-path, than I have to copy these files in to the compilers directory ... I do not like this behavior.

cu, helpy

Posted: Tue Mar 22, 2005 8:50 pm
by El_Choni
Oops, you're right. I thought something like %BASENAME% was supported for the tools command line.

About the exe with debugger, I didn't know you could create it with the debugger included and the final exe name. Makes sense, of course.

Posted: Tue Mar 22, 2005 10:59 pm
by Rescator
Hmm. Hopefully the windows port off the new PBIDE will have this.
So far I've been using jaPBe and it lucikly seems to change work directory to the source folder so you can just leave all dll's and .ini files in the source folder.

OTH shouldn't be that hard to change the origial IDE to use a workfolder either.

But right now I'm sticking with jaPBe until the new PBIDE is avail on windows :)

Posted: Wed Mar 23, 2005 7:58 am
by helpy
Rescator wrote:So far I've been using jaPBe and it lucikly seems to change work directory to the source folder so you can just leave all dll's and .ini files in the source folder.
In jaPBe with [F5] (Compile/Run) and [F6] (Compile/Debug) the EXE with the name "Purebasic[Number].exe" is also created in the Compilers directory (.\PureBasic\Compilers).

With "Create Executable" you can choose where to put the exe file (in jaPBe and also in the PureBasic editor). BUT in this case the exe is always compiled without the compiler option /DEBUGGER.

In jaPBe you the the menu point Project->Compile manual... where you can give your own compiler switches. This is the only way to put a debug-version of the exe file in a different directory and not in the compilers directory.

cu, helpy