Difference between revisions of "Installing Code::Blocks from source on Linux"

From Code::Blocks
Line 44: Line 44:
 
  mkdir build_gtk2_shared_monolithic_unicode
 
  mkdir build_gtk2_shared_monolithic_unicode
 
  cd build_gtk2_shared_monolithic_unicode
 
  cd build_gtk2_shared_monolithic_unicode
  ../configure --prefix=/opt/wx/2.6 \
+
  ../configure --prefix=/opt/wx/2.8 \
 
         --enable-xrc \
 
         --enable-xrc \
 
         --enable-monolithic \
 
         --enable-monolithic \
 
         --enable-unicode
 
         --enable-unicode
 
  make
 
  make
make -C contrib/src/stc
 
 
  su
 
  su
 
  make install
 
  make install
make -C contrib/src/stc install
 
 
  exit
 
  exit
  
(Note: it's not necessary to make or install stc if you're compiling cvs HEAD or Code::Blocks newer than RC1)
+
Add /opt/wx/2.8/bin to the PATH (if you're shell is bash then edit /etc/profile or ~/.bash_profile)
 
 
Add /opt/wx/2.6/bin to the PATH (if you're shell is bash then edit /etc/profile or ~/.bash_profile)
 
 
(On Suse 10.1 edit /etc/profile.local, it will only be available after a new login).  an example PATH
 
(On Suse 10.1 edit /etc/profile.local, it will only be available after a new login).  an example PATH
  export PATH=/usr/bin:/opt/wx/2.6/bin:$PATH
+
  export PATH=/usr/bin:/opt/wx/2.8/bin:$PATH
  
 
'''Note:''' On Ubuntu Hoary it was necessary to check "Run command as login shell"  
 
'''Note:''' On Ubuntu Hoary it was necessary to check "Run command as login shell"  
 
in the gnome-terminal profile-settings, otherwise the PATH changes are not available in a gnome-terminal window.
 
in the gnome-terminal profile-settings, otherwise the PATH changes are not available in a gnome-terminal window.
  
add /opt/wx/2.6/lib to /etc/ld.so.conf (nano /etc/ld.so.conf)
+
add /opt/wx/2.8/lib to /etc/ld.so.conf (nano /etc/ld.so.conf)
 
then run:
 
then run:
 
  ldconfig
 
  ldconfig
 
  source /etc/profile
 
  source /etc/profile
  
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.
+
That's it.  Now the linker will look in /opt/wx/2.8/lib for wx libraries and you will have a monolithic shared library unicode build.
  
 
To check that things are working, type:
 
To check that things are working, type:
 
  wx-config --prefix
 
  wx-config --prefix
which should give you /opt/wx/2.6
+
which should give you /opt/wx/2.8
 
  wx-config --libs
 
  wx-config --libs
 
which should have at least
 
which should have at least
  -L/opt/wx/2.6/lib -lwx_gtk2-2.6
+
  -L/opt/wx/2.8/lib -lwx_gtk2-2.8
 
but can contain other flags as well.
 
but can contain other flags as well.
 
  which wx-config
 
  which wx-config
should return /opt/wx/2.6/bin/wx-config
+
should return /opt/wx/2.8/bin/wx-config
  
 
===Code::Blocks installation===
 
===Code::Blocks installation===

Revision as of 06:41, 15 December 2007

These are instructions on how to build Code::Blocks under Linux. These instructions should work for all Linux distros, as we'll be installing from sources.

Prerequisites

In order to sucesfully compile Code::Blocks, the wxWidgets (wxGTK-2.8.0 or later) cross-platform UI library must be installed. 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. What is not covered here, is the wxWidgets prerequisites. The most important being GTK2, of course! Let me stress it here, while it's early: GTK2 is required, not GTK1, for Code::Blocks to be operational.

You do not need to Compile wxWidgets if your distribution has wxGTK 2.8 and wxGTK 2.8-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.

All the instructions below, assume an existing directory named ~/devel. If you 'll be using a different one, adjust the path to match. As a first step create this directory:

mkdir ~/devel

wxGTK installation

Getting wxGTK

Visit the wxWidgets web site. Click the "Download" button at the top of the page. Under wxWidgets 2.8.7 downloads, select wxGTK. Save the file in ~/devel.

Uncompressing the wxGTK sources

After the download finishes, switch to ~/devel:

cd ~/devel

Now, untar the wxGTK sources:

tar zxf wxGTK-2.8.7.tar.gz

Switch to the wxGTK directory

cd wxGTK-2.8.7

wxWidgets build

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).

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.

mkdir build_gtk2_shared_monolithic_unicode
cd build_gtk2_shared_monolithic_unicode
../configure --prefix=/opt/wx/2.8 \
       --enable-xrc \
       --enable-monolithic \
       --enable-unicode
make
su
make install
exit

Add /opt/wx/2.8/bin to the PATH (if you're shell is bash then edit /etc/profile or ~/.bash_profile) (On Suse 10.1 edit /etc/profile.local, it will only be available after a new login). an example PATH

export PATH=/usr/bin:/opt/wx/2.8/bin:$PATH

Note: On Ubuntu Hoary it was necessary to check "Run command as login shell" in the gnome-terminal profile-settings, otherwise the PATH changes are not available in a gnome-terminal window.

add /opt/wx/2.8/lib to /etc/ld.so.conf (nano /etc/ld.so.conf) then run:

ldconfig
source /etc/profile

That's it. Now the linker will look in /opt/wx/2.8/lib for wx libraries and you will have a monolithic shared library unicode build.

To check that things are working, type:

wx-config --prefix

which should give you /opt/wx/2.8

wx-config --libs

which should have at least

-L/opt/wx/2.8/lib -lwx_gtk2-2.8

but can contain other flags as well.

which wx-config

should return /opt/wx/2.8/bin/wx-config

Code::Blocks installation

Downloading Code::Blocks

You can get Code::Blocks source code in one of two ways:

  • Download the latest source package, or
  • Get the latest sources from the SVN repository.

Both methods, are described below.

Getting the latest sources from SVN

IMPORTANT NOTICE: The Sourceforge CVS is no longer used although it still exists

Enter your development directory:

cd ~/devel

Then checkout the source using one of these methods.

This will create the directory trunk. Change to the source code directory, by issuing the following command:

cd trunk

Building Code::Blocks SVN

If you are a Gentoo user, please see Compiling_Code::Blocks_in_Gentoo.

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.

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:

./bootstrap

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:

aclocal:configure.in:61: warning: macro `AM_OPTIONS_WXCONFIG' not found in library

Then aclocal is having trouble finding the wxWidgets .m4 files. You can do one of two things: To just get bootstrap to find the path this time do:

export ACLOCAL_FLAGS="-I `wx-config --prefix`/share/aclocal"

To change the aclocal search path more permanently do:

echo `wx-config --prefix`/share/aclocal >> /usr/share/aclocal/dirlist

Then aclocal will also search somewhere like /opt/wx/2.6/share/aclocal

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).

If you get something like

The usual way to define `LIBTOOL' is to add `AC_PROG_LIBTOOL'

it can be solved by something like: (adapt path, use `wx-config --prefix` is necessary)

ACLOCAL_FLAGS="-I /usr/share/aclocal" ./bootstrap

(*Note// If you run ./bootstrap and get errors like:

: bad interpreter: File not found

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. //tiwag 051008*)
Or, instead of downloading from SVN, you might consider using the little command line tool dos2unix, which normally comes with most distributions. //lizzarddude060103
If configure aborts with some unspecific error message(".infig.status: error: cannot find input file: Makefile"), you might consider also running

dos2unix bootstrap acinclude.m4 codeblocks.pc.in configure.in Makefile.am

before running bootstrap

Once you've run the bootstrap script, installing is as simple as:

./configure
make
make install

If you have multiple versions of wxWidgets installed or kept them inplace, you can use ./configure --with-wx-config=/path/to/wx-config

To uninstall you can later run:

make uninstall

If you want to recompile everything, first run:

make clean
make distclean
make clean-bin
make clean-zipfiles

and then follow the above sequence for installing.

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:

./configure --prefix=/opt/codeblocks-svn

or similar. Then you can later install a different build like:

./configure --prefix=/opt/codeblocks2-svn

followed by 'make && make install' as usual.

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:

./configure --with-contrib-plugins=all

followed by 'make && make install' as usual.

To see a list of other options available for configuring the build of CodeBlocks do:

./configure --help

To compile under gentoo, use

./configure --with-wx-config=wx-config-2.6