https://wiki.codeblocks.org/api.php?action=feedcontributions&user=Daniel15&feedformat=atomCode::Blocks - User contributions [en]2024-03-28T17:17:34ZUser contributionsMediaWiki 1.35.0https://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Linux&diff=4741Installing Code::Blocks from source on Linux2007-06-10T10:11:39Z<p>Daniel15: Minor grammar fix</p>
<hr />
<div>[[Category:Installing Code::Blocks]]<br />
[[Category:Installing Code::Blocks from source]]<br />
These are instructions on how to build Code::Blocks under Linux. I 've ran and verified this procedure to work under SuSE 9.2 and Fedora Core 3. These instructions should work for all Linux distros, as we'll be installing from sources.<br />
<br />
===Prerequisites===<br />
<br />
In order to sucesfully compile Code::Blocks, the wxWidgets (<u>wxGTK-2.6.1 or later</u>) cross-platform UI library <u>must be installed</u>. In this document, it is not assumed that it is already installed in your system and instructions are given on how to download, build and install it.<br />
What is '''not''' covered here, is the wxWidgets prerequisites. The most important being GTK2, of course!<br />
Let me stress it here, while it's early: <u>GTK2 is required</u>, not GTK1, for Code::Blocks to be operational.<br />
<br />
You do not need to Compile wxWidgets if your distribution has wxGTK 2.6 and wxGTK 2.6-dev package available. A quick search for "wxGTK" through your respective package manager should show bring up the needed packages. After you have installed successfully you can moving on the the Installing Code::Blocks portion. If you are using Ubuntu and have installed the wxGTK package, you must also have the dev version as well as the "wx-common" package in order to successfully compile Code::Blocks.<br />
<br />
All the instructions below, assume an existing directory named <tt>~/devel</tt>. If you 'll be using a different one, adjust the path to match.<br />
As a first step create this directory:<br />
<br />
<pre>mkdir ~/devel</pre><br />
<br />
===wxGTK installation===<br />
<br />
====Getting wxGTK====<br />
<br />
Visit the [http://www.wxwidgets.org wxWidgets web site]. Click the "Download" button at the top of the page. Under wxWidgets 2.6.3 downloads, select wxGTK. Save the file in <tt>~/devel</tt>.<br />
<br />
wxWidgets project has released two patches for 2.6.3 release. Click the "Patches" in the left side of the page. Download the Patch 2, either in zip or tar.gz format. Save the file in <tt>~/devel</tt><br />
<br />
====Uncompressing the wxGTK sources====<br />
<br />
After the download finishes, switch to <tt>~/devel</tt>:<br />
<br />
<pre>cd ~/devel</pre><br />
<br />
Now, untar the wxGTK sources:<br />
<br />
<pre>tar zxf wxGTK-2.6.3.tar.gz</pre><br />
<br />
Move the patch to the wxGTK directory<br />
<br />
<pre>mv wxWidgets-2.6.3-Patch-2.tar.gz wxGTK-2.6.3</pre><br />
<br />
or<br />
<br />
<pre>mv wxWidgets-2.6.3-Patch-2.zip wxGTK-2.6.3</pre><br />
<br />
Switch to the wxGTK directory<br />
<br />
<pre>cd wxGTK-2.6.3</pre><br />
<br />
Extract the patch<br />
<br />
<pre>tar zxf wxWidgets-2.6.3-Patch-2.tar.gz</pre><br />
<br />
or<br />
<br />
<pre>unzip -fo wxWidgets-2.6.3-Patch-2.zip</pre><br />
<br />
Remove the patch file<br />
<br />
<pre>rm wxWidgets-2.6.3-Patch-2.tar.gz</pre><br />
<br />
or<br />
<br />
<pre>rm wxWidgets-2.6.3-Patch-2.zip</pre><br />
<br />
====wxWidgets build====<br />
<br />
Here we will create a seperate build directory instead of building from the src directory, so that we can easily rebuild with different options (unicode / ansi, monolithic / many libs, etc).<br />
<br />
The documentation says the default is for gtk2 to use unicode and wx > 2.5 to build as a monolithic library. This doesn't appear to be the case, so these flags are passed to configure.<br />
<br />
mkdir build_gtk2_shared_monolithic_unicode<br />
cd build_gtk2_shared_monolithic_unicode<br />
../configure --prefix=/opt/wx/2.6 \<br />
--enable-xrc \<br />
--enable-monolithic \<br />
--enable-unicode<br />
make<br />
make -C contrib/src/stc<br />
su<br />
make install<br />
make -C contrib/src/stc install<br />
exit<br />
<br />
(Note: it's not necessary to make or install stc if you're compiling cvs HEAD or Code::Blocks newer than RC1)<br />
<br />
Add /opt/wx/2.6/bin to the PATH (if you're shell is bash then edit /etc/profile or ~/.bash_profile)<br />
(On Suse 10.1 edit /etc/profile.local, it will only be available after a new login). an example PATH<br />
export PATH=/usr/bin:/opt/wx/2.6/bin:$PATH<br />
<br />
'''Note:''' On Ubuntu Hoary it was necessary to check "Run command as login shell" <br />
in the gnome-terminal profile-settings, otherwise the PATH changes are not available in a gnome-terminal window.<br />
<br />
add /opt/wx/2.6/lib to /etc/ld.so.conf (nano /etc/ld.so.conf)<br />
then run:<br />
ldconfig<br />
source /etc/profile<br />
<br />
That's it. Now the linker will look in /opt/wx/2.6/lib for wx libraries and you will have a monolithic shared library unicode build.<br />
<br />
To check that things are working, type:<br />
wx-config --prefix<br />
which should give you /opt/wx/2.6<br />
wx-config --libs<br />
which should have at least<br />
-L/opt/wx/2.6/lib -lwx_gtk2-2.6<br />
but can contain other flags as well.<br />
which wx-config<br />
should return /opt/wx/2.6/bin/wx-config<br />
<br />
===Code::Blocks installation===<br />
<br />
====Downloading Code::Blocks====<br />
<br />
You can get Code::Blocks source code in one of two ways:<br />
* Download the latest source package, or<br />
* Get the latest sources from the SVN repository.<br />
Both methods, are described below.<br />
<br />
<br />
=====Downloading the latest source package=====<br />
<br />
Go to the Code::Blocks [https://www.codeblocks.org web site] and download the latest source package. This would be the " Code::Blocks IDE version 1.0rc2 source code (tarball)" codeblocks-1.0rc2.tar.gz.<br />
Save this file in <tt>~/devel</tt> and then untar it:<br />
<pre>cd ~/devel<br />
tar zxf codeblocks-1.0rc2.tar.gz</pre><br />
This will create the directory <tt>~/devel/codeblocks-1.0rc2</tt>.<br />
Change to the source code directory, by issuing the following command:<br />
<pre>cd codeblocks-1.0rc2</pre><br />
<br />
=====Getting the latest sources from SVN=====<br />
'''IMPORTANT NOTICE: The Sourceforge CVS is no longer used although it still exists'''<br />
<br />
Enter your development directory:<br />
<pre>cd ~/devel</pre><br />
<br />
Then checkout the source using one of [https://www.codeblocks.org/source_code.shtml these] methods.<br />
<br />
This will create the directory <tt>trunk</tt>.<br />
Change to the source code directory, by issuing the following command:<br />
<br />
<pre>cd trunk</pre><br />
<br />
====Building Code::Blocks RC2 and SVN====<br />
If you are a Gentoo user, please see [[Compiling_Code::Blocks_in_Gentoo]].<br />
<br />
Before beginning, it is often a good idea to check you have recent versions of autoconf and automake - repositories versions are not always recent enough.<br />
<br />
If you're compiling the svn trunk versions of CodeBlocks (or future versions) then the unix build has switched to autotools. So first build wxWidgets as described above and then build CodeBlocks as follows:<br />
<br />
./bootstrap<br />
<br />
This sets up the configure script and its dependencies. It only needs to be run once (after downloading the source from svn). '''If you get errors like:'''<br />
aclocal:configure.in:61: warning: macro `AM_OPTIONS_WXCONFIG' not found in library<br />
Then aclocal is having trouble finding the wxWidgets .m4 files. You can do one of two things:<br />
To just get bootstrap to find the path this time do:<br />
<!-- *********** Bad syntax... removed 2006-08-28 by BentFX ****************************<br />
export ACLOCAL_FLAGS="--acdir=`wx-config --prefix`/share/aclocal"<br />
<br />
: Note: The above command resulted in missing macros when running ./bootstrap for me. Setting an additional search path instead of overwriting like above worked for me. In case of missing macros try <br />
***********************************************************************************--><br />
<pre>export ACLOCAL_FLAGS="-I `wx-config --prefix`/share/aclocal"</pre> <!--[[User:Jabber|Jabber]] 06:24, 2 August 2006 (EDT)--><br />
<br />
To change the aclocal search path more permanently do:<br />
echo `wx-config --prefix`/share/aclocal >> /usr/share/aclocal/dirlist<br />
Then aclocal will also search somewhere like /opt/wx/2.6/share/aclocal<br />
<br />
'''Note for Ubuntu users:''' The above is not the correct way to fix the AM_* errors. Rather, you only need to install the package named "wx-common" (Universe repository).<br />
<br />
If you get something like<br />
The usual way to define `LIBTOOL' is to add `AC_PROG_LIBTOOL'<br />
<br />
it can be solved by something like: (adapt path, use `wx-config --prefix` is necessary)<br />
<br />
ACLOCAL_FLAGS="-I /usr/share/aclocal" ./bootstrap<br />
<br />
(*Note// '''If you run ./bootstrap and get errors like''':<br />
: bad interpreter: File not found<br />
then there exists a problem with DOS line-endings. i had this error after i tried to build a codeblocks from sources which were checked out with cvs on a windows machine. After i checked out a fresh copy of codeblocks from cvs under Ubuntu linux (see above topic: Downloading the latest source package fom SVN), all errors were gone. <br />
//tiwag 051008*)<br><br />
Or, instead of downloading from SVN, you might consider using the little command line tool dos2unix, which normally comes with most distributions. //lizzarddude060103<br />
<br><br />
If configure aborts with some unspecific error message(".infig.status: error: cannot find input file: Makefile"), you might consider also running<br />
dos2unix bootstrap acinclude.m4 codeblocks.pc.in configure.in Makefile.am<br />
before running bootstrap<br />
<br />
Once you've run the bootstrap script, installing is as simple as:<br />
./configure<br />
make<br />
make install<br />
<br />
If you have multiple versions of wxWidgets installed or kept them inplace, you can use<br />
./configure --with-wx-config=/path/to/wx-config<br />
<br />
To uninstall you can later run:<br />
make uninstall<br />
<br />
If you want to recompile everything, first run:<br />
make clean<br />
make distclean<br />
make clean-bin<br />
make clean-zipfiles<br />
and then follow the above sequence for installing.<br />
<br />
By default, CodeBlocks will install to /usr/local. If you want it in its own tree (so you can have multiple versions of CodeBlocks, each in its own subdirectory of /opt) replace the above ./configure command with:<br />
./configure --prefix=/opt/codeblocks-svn<br />
or similar. Then you can later install a different build like:<br />
./configure --prefix=/opt/codeblocks2-svn<br />
followed by 'make && make install' as usual.<br />
<br />
By default, CodeBlocks will not compile the contributed plugins from SVN. If you want to compile / install them too, replace the above ./configure command with:<br />
./configure --enable-contrib<br />
followed by 'make && make install' as usual.<br />
<br />
To see a list of other options available for configuring the build of CodeBlocks do:<br />
./configure --help<br />
<br />
To compile under gentoo, use<br />
./configure --with-wx-config=wx-config-2.6<br />
<br />
====Building Code::Blocks RC1 and former====<br />
<br />
To build Code::Blocks all you have to do now is type:<br />
<br />
<pre>make -f Makefile.unix</pre><br />
<br />
This will build everything: the application and the plugins. The final step is to update the working environment for your system:<br />
<br />
<pre>make -f Makefile.unix update</pre><br />
<br />
The following notes about converting the line endings does '''not''' apply to the CVS Version! The "update" script included there works just fine.<br />
<br />
'''Important note:''' Don't run that final make yet! The "update" script seems to be using Dos character encoding, which will result in its failure to run on Linux. To fix this, use dos2unix:<br />
<br />
To install it in Gentoo, do:<br />
<br />
# emerge -av dos2unix<br />
<br />
In Debian and Ubuntu, do (as root, or using sudo etc.):<br />
<br />
# apt-get install sysutils<br />
<br />
This will install dos2unix. Now we are ready to convert the script.<br />
# dos2unix -n update update.unix<br />
# chmod +x update.unix<br />
# ./update.unix<br />
The first line converts the script character encoding, the second makes it executable and the third runs it. This trick is from a forum post by ilkapo.<br />
<br />
OK. Now that the update script is converted to unix format, you can run the final make:<br />
<br />
<pre>make -f Makefile.unix update</pre><br />
<br />
If everything's gone well, congratulations! You should be able to launch Code::Blocks by running the generated <tt>run.sh</tt> script in the <tt>output</tt> subdir:<br />
<br />
<pre>output/run.sh</pre><br />
<br />
This script can be ran from anywhere in your system so, yes, you can make a shortcut to it on your desktop ;)<br />
<br />
Enjoy!</div>Daniel15