Code::Blocks
September 19, 2014, 05:50:22 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Don't forget to check the Nightly builds in the appropriate forum.
 
   Home   Help Search Login Register  :: WebsiteWiki  
Pages: 1 [2] 3 4 5 6 7   Go Down
  Send this topic  |  Print  
Author Topic: Portable Code::Blocks  (Read 65886 times)
mrTeoc
Guest
« Reply #15 on: April 14, 2009, 03:40:26 am »

This is great! I really needed this, because I get to work on random pcs very often.
Logged
Biplab
Developer
Lives here!
*****
Offline Offline

Posts: 1853


WWW
« Reply #16 on: April 14, 2009, 06:01:55 am »

I think the CbLauncher.exe 0.11 version should be uploaded so the people don't need to download the whole package from:

http://files.filefront.com/Portable+CB+5526+bin7z/;13582845;/fileinfo.html

I've uploaded it to my blog. You can download it from the following link-

Quote

I've also written steps to launch C::B nightlies (> rev 5534) in a portable manner using CbLauncher in the above post.
Logged

Be a part of the solution, not a part of the problem.
rokan1
Newcomer
*
Offline Offline

Posts: 3


« Reply #17 on: April 16, 2009, 05:16:28 pm »

I made a small batch file which temporarily modifies essential environment variables to make "portable" version not only for codeblocks but also msys and mingw.
Assuming that you have copied the tools to /MingW and /msys and /codeblocks on your usb you can copy the following script to eg portable.bat on your usb.
After running this bat file, just type codeblocks and everything should work fine - if it touches configuration files, it uses the locations within USB.
Be sure you set $(CODEBLOCKS)/../Mingw as the location for the gcc toolchain.
You can also change cmd.exe to codeblocks.exe in the last line of this batch file to start codeblocks immediately.

Code:
@echo off

echo Setting environment variables and checking for directories availability:
:: Get the current batch fille drive and set it as homedrive
for %%x in (%0) do set HOMEDRIVE=%%~dsx
set HOMEDRIVE

:: Set user as USERNAME
set USERNAME=user
set USERNAME


:: Set \home\%USERNAME% as HOMEPATH and assure the directory exists
mkdir %HOMEDRIVE%\home
set HOMEPATH=\home\%USERNAME%
set HOMEPATH
mkdir %HOMEDRIVE%%HOMEPATH%
mkdir "%HOMEDRIVE%%HOMEPATH%\Desktop

:: Set %HOMEDRIVE%%HOMEPATH% as USERPROFILE
set USERPROFILE=%HOMEDRIVE%%HOMEPATH%
set USERPROFILE

::set %HOMEDRIVE%%HOMEPATH%\ApplicationData as APPDATA
set APPDATA=%HOMEDRIVE%%HOMEPATH%\ApplicationData
set APPDATA
mkdir %APPDATA%


:: Set %HOMEDRIVE%\home\AllUsers as ALLUSERSPROFILE and assure it exists
set ALLUSERSPROFILE=%HOMEDRIVE%\home\AllUsers
set ALLUSERSPROFILE
mkdir %ALLUSERSPROFILE%


echo Adding %HOMEDRIVE%\MinGW\bin;%HOMEDRIVE%\msys\1.0\bin;%HOMEDRIVE%\codeblocks to the PATH
set PATH=%HOMEDRIVE%\MinGW\bin;%HOMEDRIVE%\msys\1.0\bin;%HOMEDRIVE%\codeblocks;%PATH%
set PATH

CALL cmd.exe


Logged
ollydbg
Developer
Lives here!
*****
Offline Offline

Posts: 4068


Interests on OpenCV and Robotics


WWW
« Reply #18 on: April 16, 2009, 05:29:50 pm »

I made a small batch file which temporarily modifies essential environment variables to make "portable" version not only for codeblocks but also msys and mingw.
Assuming that you have copied the tools to /MingW and /msys and /codeblocks on your usb you can copy the following script to eg portable.bat on your usb.
After running this bat file, just type codeblocks and everything should work fine - if it touches configuration files, it uses the locations within USB.
Be sure you set $(CODEBLOCKS)/../Mingw as the location for the gcc toolchain.
You can also change cmd.exe to codeblocks.exe in the last line of this batch file to start codeblocks immediately.

Code:
@echo off

echo Setting environment variables and checking for directories availability:
:: Get the current batch fille drive and set it as homedrive
for %%x in (%0) do set HOMEDRIVE=%%~dsx
set HOMEDRIVE

:: Set user as USERNAME
set USERNAME=user
set USERNAME


:: Set \home\%USERNAME% as HOMEPATH and assure the directory exists
mkdir %HOMEDRIVE%\home
set HOMEPATH=\home\%USERNAME%
set HOMEPATH
mkdir %HOMEDRIVE%%HOMEPATH%
mkdir "%HOMEDRIVE%%HOMEPATH%\Desktop

:: Set %HOMEDRIVE%%HOMEPATH% as USERPROFILE
set USERPROFILE=%HOMEDRIVE%%HOMEPATH%
set USERPROFILE

::set %HOMEDRIVE%%HOMEPATH%\ApplicationData as APPDATA
set APPDATA=%HOMEDRIVE%%HOMEPATH%\ApplicationData
set APPDATA
mkdir %APPDATA%


:: Set %HOMEDRIVE%\home\AllUsers as ALLUSERSPROFILE and assure it exists
set ALLUSERSPROFILE=%HOMEDRIVE%\home\AllUsers
set ALLUSERSPROFILE
mkdir %ALLUSERSPROFILE%


echo Adding %HOMEDRIVE%\MinGW\bin;%HOMEDRIVE%\msys\1.0\bin;%HOMEDRIVE%\codeblocks to the PATH
set PATH=%HOMEDRIVE%\MinGW\bin;%HOMEDRIVE%\msys\1.0\bin;%HOMEDRIVE%\codeblocks;%PATH%
set PATH

CALL cmd.exe


Thanks.
My question is:
Do I need the "CBLuncher.exe" supplied by BipLab to run CB?
Or I just type codeblocks.exe  as you said?

Thanks. Cheesy
Logged

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.
Biplab
Developer
Lives here!
*****
Offline Offline

Posts: 1853


WWW
« Reply #19 on: April 16, 2009, 05:37:59 pm »

@Rokan,

I haven't tried this. But having a complete development environment should be nice to many users. Thanks for sharing this.


@OllyDbg,

So far CbLauncher does the similar thing before launching Code::Blocks. Assuming the batch file is error free, you do not need CbLauncher.exe v0.1.1 to make C::B portable. You can use this batch file.
Logged

Be a part of the solution, not a part of the problem.
ollydbg
Developer
Lives here!
*****
Offline Offline

Posts: 4068


Interests on OpenCV and Robotics


WWW
« Reply #20 on: April 16, 2009, 05:44:24 pm »

@Rokan,

I haven't tried this. But having a complete development environment should be nice to many users. Thanks for sharing this.


@OllyDbg,

So far CbLauncher does the similar thing before launching Code::Blocks. Assuming the batch file is error free, you do not need CbLauncher.exe v0.1.1 to make C::B portable. You can use this batch file.

Thanks for the quick response. Cheesy I will try it.

By the way, comparing a batch file with a exe file, I do prefer the former one, because it can be easily add to trunk. Cheesy
Logged

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.
Biplab
Developer
Lives here!
*****
Offline Offline

Posts: 1853


WWW
« Reply #21 on: April 16, 2009, 05:50:57 pm »

By the way, comparing a batch file with a exe file, I do prefer the former one, because it can be easily add to trunk. Cheesy

You are forgetting that exe file has a corresponding source file which should not be difficult to add to trunk. Nobody will add a exe file to trunk unless absolutely necessary.
Logged

Be a part of the solution, not a part of the problem.
ollydbg
Developer
Lives here!
*****
Offline Offline

Posts: 4068


Interests on OpenCV and Robotics


WWW
« Reply #22 on: April 16, 2009, 05:58:25 pm »

By the way, comparing a batch file with a exe file, I do prefer the former one, because it can be easily add to trunk. Cheesy

You are forgetting that exe file has a corresponding source file which should not be difficult to add to trunk. Nobody will add a exe file to trunk unless absolutely necessary.

Oh, yes. I really forget that. Cheesy
I notices that there is an DLL file named "exchndl.dll" in the trunk\src\, I'm not sure why we need this file :shock:.
Logged

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.
Biplab
Developer
Lives here!
*****
Offline Offline

Posts: 1853


WWW
« Reply #23 on: April 16, 2009, 06:00:48 pm »

exchndl.dll is used generate crash report for Code::Blocks on Windows.
Logged

Be a part of the solution, not a part of the problem.
rokan1
Newcomer
*
Offline Offline

Posts: 3


« Reply #24 on: April 16, 2009, 11:06:38 pm »


Thanks.
My question is:
Do I need the "CBLuncher.exe" supplied by BipLab to run CB?
Or I just type codeblocks.exe  as you said?

Thanks. Cheesy

No, you do not need CBLuncher.exe and all that jazz, just unpack standard codeblocks  (eg from nightly builds) to /codeblocks directory on USB

I have found a bug in codeblocks: It does not use APPDATA to store various .ini files, instead it uses hard-codded "Application Data" subdirectory within users directory, which causes messing the root (on USB) with various files. As a work-arround I have modified the directories on USB to look like "standard windows" ones (although I prefer short unix-like ones where you do not need to type quotes to get around that stupid spaces). The script launches codeblocks.exe and also command prompt with all variables set - where you can eg launch real bash shell from msys by typing "sh". Here is modified script expecting MinGW, msys, and codeblocks directories as before:

Code:

@echo off


echo Setting environment variables and checking for directories availability:
:: Get the current batch fille drive and set it as homedrive
for %%x in (%0) do set HOMEDRIVE=%%~dsx
set HOMEDRIVE

:: Set user as USERNAME
set USERNAME=user
set USERNAME


:: Set \Documents and Settings\%USERNAME% as HOMEPATH and assure the directory exists
set HOMEPATH=\Documents and Settings\%USERNAME%
set HOMEPATH
mkdir "%HOMEDRIVE%%HOMEPATH%"
mkdir "%HOMEDRIVE%%HOMEPATH%\Desktop"

:: Set %HOMEDRIVE%%HOMEPATH% as USERPROFILE
set USERPROFILE=%HOMEDRIVE%%HOMEPATH%
set USERPROFILE



::set "%HOMEDRIVE%%HOMEPATH%\Application Data" as APPDATA
set APPDATA=%HOMEDRIVE%%HOMEPATH%\Application Data
mkdir "%APPDATA%"
set APPDATA



:: Set %HOMEDRIVE%\home\All Users as ALLUSERSPROFILE and assure it exists
set ALLUSERSPROFILE=%HOMEDRIVE%\Documents and settings\All Users
mkdir "%ALLUSERSPROFILE%"
mkdir "%ALLUSERSPROFILE%\Application Data"


echo Preppending %HOMEDRIVE%\MinGW\bin;%HOMEDRIVE%\msys\1.0\bin;%HOMEDRIVE%\codeblocks to the PATH
set PATH=%HOMEDRIVE%\MinGW\bin;%HOMEDRIVE%\msys\1.0\bin;%HOMEDRIVE%\codeblocks;%PATH%

start codeblocks.exe

cmd.exe


Logged
MortenMacFly
Administrator
Lives here!
*****
Offline Offline

Posts: 8639



« Reply #25 on: April 17, 2009, 01:14:50 am »

Here is modified script expecting MinGW, msys, and codeblocks directories as before:
Notice that this script won't work on non-English Windows platforms.

@Biplab: Did you commit the sources for CbLauncher, too? I could not find them... Or do I need to use the one from the archive?
Logged

Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ
Biplab
Developer
Lives here!
*****
Offline Offline

Posts: 1853


WWW
« Reply #26 on: April 17, 2009, 02:00:13 am »

I have found a bug in codeblocks: It does not use APPDATA to store various .ini files, instead it uses hard-codded "Application Data" subdirectory within users directory, which causes messing the root (on USB) with various files.

Code::Blocks now uses APPDATA to save configuration files. Download a nightly (Rev > 5534) which will have this modification.


@Biplab: Did you commit the sources for CbLauncher, too? I could not find them... Or do I need to use the one from the archive?

No I didn't commit source of CbLauncher. It can be downloaded from my blog. If others have no objection, I can commit it to trunk.
Logged

Be a part of the solution, not a part of the problem.
MortenMacFly
Administrator
Lives here!
*****
Offline Offline

Posts: 8639



« Reply #27 on: April 17, 2009, 07:10:14 am »

No I didn't commit source of CbLauncher. It can be downloaded from my blog. If others have no objection, I can commit it to trunk.
You can submit the tool in the "tools" sub-folder in src.

BTW: How does that work under Linux? If I got the changes right they are Windows only and under Linux it still uses the standard path's which would be not on (e.g.) a USB stick...?!
Logged

Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ
jens
Administrator
Lives here!
*****
Online Online

Posts: 6595



WWW
« Reply #28 on: April 17, 2009, 10:50:14 am »

BTW: How does that work under Linux? If I got the changes right they are Windows only and under Linux it still uses the standard path's which would be not on (e.g.) a USB stick...?!

On linux a simple script should be enough.

I just hacked one to use C::B compiled with C::B.

Put the following script inside the folder where the run.sh-script is and start it.
You might have to deal with LD_LIBRARY_PATH for a wxWidgets-installation, if you need to have it on the stick (or whatever), too.
But that's another thing and makes it not so easy to make C::B portable on linux.

If you have a C::B installed on the machine and all you want is to have portable configuration, you can use a call to codeblocks instead of running run.sh.

Code:
#!/bin/sh

xhost +
export HOME=`pwd`
./run.sh
xhost -

By the way:
Instead of dealing with APPDATA and HOME (that seems to be a little hacky), it would be better (in my opinion) to pass an alternative conf-dir to C::B as start-parameter and provide a sdk-function that returns the actual used conf-dir (for the plugins or whatever needs it).
Logged

Regards

Jens  Debian - nightlies (and release) : http://apt.jenslody.de/ Fedora [18 - 20]- and CentOS/RedHat [5, 6 & 7] - nightlies : http://rpm.jenslody.de/
Biplab
Developer
Lives here!
*****
Offline Offline

Posts: 1853


WWW
« Reply #29 on: April 19, 2009, 06:11:25 am »

No I didn't commit source of CbLauncher. It can be downloaded from my blog. If others have no objection, I can commit it to trunk.
You can submit the tool in the "tools" sub-folder in src.

BTW: How does that work under Linux? If I got the changes right they are Windows only and under Linux it still uses the standard path's which would be not on (e.g.) a USB stick...?!

I'll put that code in trunk.

Creating portable version on Linux is not easy. I mean you build binary on Fedora and then you can't expect that it will run fine on other system, e.g. Ubuntu. Yes, it's possible to ask Code::Blocks to save configuration file to any specified folder. I have made this change only for Windows where many people prefer portable application.


By the way:
Instead of dealing with APPDATA and HOME (that seems to be a little hacky), it would be better (in my opinion) to pass an alternative conf-dir to C::B as start-parameter and provide a sdk-function that returns the actual used conf-dir (for the plugins or whatever needs it).

Both way it's a hack. If you use APPDATA or HOME, you are asking Code::Blocks to use another directory by pointing to by modifying corresponding environmental variables locally. On the other hand if we provide it as an option, we are still asking it to use another folder as the configuration folder. Using well defined environment variable to save configuration is a standard procedure.
Logged

Be a part of the solution, not a part of the problem.
Pages: 1 [2] 3 4 5 6 7   Go Up
  Send this topic  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!