Difference between revisions of "Tips'n'Tricks"

From CodeBlocks
Jump to: navigation, search
(Compiling from source)
Line 1: Line 1:
====[[Personalities]]====
+
== Personalities ==
====[[Fixing Internal Errors]]====
+
 
====[[Setting the WX_VER variable]]====
+
In Code::Blocks context, personalities are different sets of settings each tailored for a different workflow. Let me explain.
====[[Running under colinux]]====
+
 
 +
The "default" personality is, well, Code::Blocks as you know it :)
 +
 
 +
By default, all available plugins are loaded and all the manager panes are open (project manager, message manager, etc).
 +
Now, let's assume that you want a more lightweight Code::Blocks to quickly work on testing single-source files. Most plugins are not needed for this kind of job so it would be wise to remove them from the loading process. You would also like the manager panes to be hidden by default.
 +
 
 +
To accomplish the above task, a new Code::Blocks personality should be created. Here is how:
 +
 
 +
*Find the shortcut to Code::Blocks on your desktop. If there isn't any, create one.
 +
*Make a copy of this shortcut and rename it to "Code::Blocks Lite" (for example). You should now have two shortcuts to Code::Blocks on your desktop.
 +
*Right-click on the "Code::Blocks Lite" shortcut and choose "Properties". In the "Target" box, append the following magic words:
 +
*<code>--personality="Lite"</code>
 +
 
 +
:'''''Tip''''': ''if you want to see a list of all defined personalities and select which one to use, replace the above with the following'':
 +
:<tt>--personality=ask</tt>
 +
 
 +
This will cause Code::Blocks to use the "Lite" personality when it starts-up.
 +
"But we haven't defined "Lite" anywhere yet!", I hear you cry out. Fear not! Code::Blocks is smart enough to create a new personality for you, if the one you entered does not exist.
 +
 
 +
After you 've done the above changes to the "Lite" shortcut and saved it, launch Code::Blocks.
 +
Although you may see no changes, Code::Blocks will be operating under the personality "Lite". This means, effectively, that any personalities-aware configuration changes you make will be done on the "Lite" personality.
 +
 
 +
To see this in action, let's return to our example scenario and turn the "Lite" personality into really light ;)
 +
 
 +
*Go to "Plugins->Manage plugins" and disable (uncheck) all plugins except the compiler.
 +
*Now hide the "Manager" (Shift-F2) and "Messages" (F2) panes (in the "View" menu).
 +
*Exit Code::Blocks.
 +
*Launch Code::Blocks again, by clicking on the "Lite" shortcut. Everything should be as configured: no manager panes showing and just one plugin loaded. Congratulations!
 +
 
 +
But an astute reader shouts: "Hey, Code::Blocks always remembered my changes and started like it was last closed. What's the difference? Are you kidding us?"
 +
Here's where the power of personalities comes in :)
 +
 
 +
*Close Code::Blocks.
 +
*Now launch Code::Blocks by clicking on the standard shortcut (no "--personality" command-line option). Tadaa! Code::Blocks in its full capacity!
 +
 
 +
 
 +
As an overview, to define and use a new personality you just have to launch Code::Blocks with the command-line option "<tt>--personality=<name></tt>", where <tt><name></tt> is the personality's name or "<tt>ask</tt>" if you want to be asked which personality to use (of the existing ones). After that, Code::Blocks will work under the selected personality for this session.
 +
 
 +
== Setting the WX_VER variable ==
 +
 
 +
<div style="margin:0;  border:2px; padding: 2em 2em 2em 2em; background-color:#FFd6c0;">
 +
'''Obsolete:'''<br />
 +
As of November 17, 2005 Code::Blocks HEAD can only be compiled using global user variables (unless you modify the project).<br />
 +
This obviously requires a version of Code::Blocks which supports this feature, i.e. a build from HEAD after November 3, 2005.<br />
 +
No additional setup is required, you will be prompted to enter the location of your wxWidgets installation. Enjoy.
 +
</div>
 +
 
 +
 
 +
 
 +
If, while compiling Code::Blocks, you get the error: "Couldn't find library -lwxmsw$(WX_VER)" or some such, do this:
 +
*Open the build options
 +
*Open the "Custom variables" tab
 +
*"Add" a new variable, with the name of (you guessed it) WX_VER
 +
*Set its value to the appropriate thing, i.e. "242" (without the quotes)
 +
 
 +
After this, the error should be gone for good :)
 +
 
 +
== Fixing Internal Errors ==
 +
 
 +
If Code::Blocks crashes for some reason, it will often then give weird "Internal Error" messages.
 +
 
 +
I've found that they can usually be solved by deleting the Code::Blocks configuration files.  On linux, these are usually in a .CodeBlocks or .Code\:\:Blocks\ v1.0 folder in your home directory, so they can be cleared with
 +
$ rm -R ~/.Code*
 +
The Code Completion plugin used to cause these problems alot, but it's much more stable now.
 +
 
 +
== [[Running_under_colinux|Running under colinux]] ==

Revision as of 18:21, 9 April 2006

Personalities

In Code::Blocks context, personalities are different sets of settings each tailored for a different workflow. Let me explain.

The "default" personality is, well, Code::Blocks as you know it :)

By default, all available plugins are loaded and all the manager panes are open (project manager, message manager, etc). Now, let's assume that you want a more lightweight Code::Blocks to quickly work on testing single-source files. Most plugins are not needed for this kind of job so it would be wise to remove them from the loading process. You would also like the manager panes to be hidden by default.

To accomplish the above task, a new Code::Blocks personality should be created. Here is how:

  • Find the shortcut to Code::Blocks on your desktop. If there isn't any, create one.
  • Make a copy of this shortcut and rename it to "Code::Blocks Lite" (for example). You should now have two shortcuts to Code::Blocks on your desktop.
  • Right-click on the "Code::Blocks Lite" shortcut and choose "Properties". In the "Target" box, append the following magic words:
  • --personality="Lite"
Tip: if you want to see a list of all defined personalities and select which one to use, replace the above with the following:
--personality=ask

This will cause Code::Blocks to use the "Lite" personality when it starts-up. "But we haven't defined "Lite" anywhere yet!", I hear you cry out. Fear not! Code::Blocks is smart enough to create a new personality for you, if the one you entered does not exist.

After you 've done the above changes to the "Lite" shortcut and saved it, launch Code::Blocks. Although you may see no changes, Code::Blocks will be operating under the personality "Lite". This means, effectively, that any personalities-aware configuration changes you make will be done on the "Lite" personality.

To see this in action, let's return to our example scenario and turn the "Lite" personality into really light ;)

  • Go to "Plugins->Manage plugins" and disable (uncheck) all plugins except the compiler.
  • Now hide the "Manager" (Shift-F2) and "Messages" (F2) panes (in the "View" menu).
  • Exit Code::Blocks.
  • Launch Code::Blocks again, by clicking on the "Lite" shortcut. Everything should be as configured: no manager panes showing and just one plugin loaded. Congratulations!

But an astute reader shouts: "Hey, Code::Blocks always remembered my changes and started like it was last closed. What's the difference? Are you kidding us?" Here's where the power of personalities comes in :)

  • Close Code::Blocks.
  • Now launch Code::Blocks by clicking on the standard shortcut (no "--personality" command-line option). Tadaa! Code::Blocks in its full capacity!


As an overview, to define and use a new personality you just have to launch Code::Blocks with the command-line option "--personality=<name>", where <name> is the personality's name or "ask" if you want to be asked which personality to use (of the existing ones). After that, Code::Blocks will work under the selected personality for this session.

Setting the WX_VER variable

Obsolete:
As of November 17, 2005 Code::Blocks HEAD can only be compiled using global user variables (unless you modify the project).
This obviously requires a version of Code::Blocks which supports this feature, i.e. a build from HEAD after November 3, 2005.
No additional setup is required, you will be prompted to enter the location of your wxWidgets installation. Enjoy.


If, while compiling Code::Blocks, you get the error: "Couldn't find library -lwxmsw$(WX_VER)" or some such, do this:

  • Open the build options
  • Open the "Custom variables" tab
  • "Add" a new variable, with the name of (you guessed it) WX_VER
  • Set its value to the appropriate thing, i.e. "242" (without the quotes)

After this, the error should be gone for good :)

Fixing Internal Errors

If Code::Blocks crashes for some reason, it will often then give weird "Internal Error" messages.

I've found that they can usually be solved by deleting the Code::Blocks configuration files. On linux, these are usually in a .CodeBlocks or .Code\:\:Blocks\ v1.0 folder in your home directory, so they can be cleared with

$ rm -R ~/.Code*

The Code Completion plugin used to cause these problems alot, but it's much more stable now.

Running under colinux