Saturday, 13 July 2013

Building Codeblocks Ide On Puppy Linux and FatDog64

If you have tried to build Codeblocks on Puppy Linux and FatDog64, and not had much luck, then follow these steps to get it all working. I have tested these building steps on FatDog64 621 and on Precise Puppy Linux 561.

The bonus with this method of building the Codeblocks is that it will build a self contained folder that hosts it's own wxWidgets. Thus it can be executed from the same folder on many computers over the network, or just from multiple variations of Puppy Linux on one Pc. Either way, all the files go into one folder and then a simple Install script makes a link in /opt to the Codeblocks folder so you can just unzip and run. 

If you just want the Ide pre-built, I also have those available from here, otherwise continue reading.

1) You need the devx sfs file for your Puppy Linux installed. This will put the make and C++ tools on your Puppy Linux. For me I have Precise Puppy 561 and FatDog64 621.

2) Download this file of scripts used to build the Codeblocks and the wxWidgets wxGTK at the same time. Read the instructions from step 3 before downloading the source. You need specific versions etc...

3) Unzip the scripts in some folder. In this folder is a readme.txt file and also a file called about.txt. Please read these for specific instructions.

4) Download the source code for wxGTK 2.8.12 and also Codeblocks 12.11, put them in folders as outlined in the instruction text files from step 3.

5)Be very, very sure you have got all the variables setup properly(about three or four values need to be set), and I mean be sure because unless you are running a fast Pc it will take an hour to build!

6) Execute your build script from a terminal. If you have followed the instructions good it should just work.

If you really cannot make it work, then leave a comment or maybe just download the pre-built folders I have made from here.

Otherwise here are some more details

The Build Script - You can either edit the scripts provided in scripts download ot make your own copy. As you can see the build is mostly controlled just by specifying names and some paths.



# Please edit these variables to suit your setup. Personally I just put everything in
# the root of my f:\ or /dev/sda7/ on linux, and then go from there. You might
# need to do it differently.

# wxBuildName - Name of the wxBuild - Not a path - Just a unique name for the build

# wxPath - absolute path to the folder where wx source code is. 

# wxOutputDir - Where to put wx build output

# cbBuildName - The name of the codeblocks build. Not a path, just a name for the codeblocks build.

# cbPath - absolute path to the codeblocks source code.

# cbOutputDir - Where to put codeblocks build output, note this folder will be
#               linked to from opt, which is where the build thinks it is putting
#               the files, but actually they go here...

# Is it 64 bit, for FatDog64 will be 1, otherwise 0 for 32 bit

# Now execute the build using the include script
source `pwd`/xinc_util

The work script(xinc_util) - The worker script just takes the values from your build script and then actually does the build. The process is simply to build the wxWidgets, then set a bunch of variables so that Codeblocks build can see wxWidgets, then build Codeblocks and finally copy the wxWidgets into the output directory. 

This script is called xinc_util. You do not execute it yourself but rather you make your own build script which sets the values and then calls this script. 

Do not copy and paste this, just download it instead.


# This script by Turboloops -
# No rights reserved, use at own risk!

if [ "$1" = "" ]; then
  echo "This script must be included!"
  exit 1

THE_SCRIPT_DIR="`echo "${0}" | sed 's%/[^/][^/]*$%%'`/"
if [ "${THE_SCRIPT_DIR}" = "./" ]; then

echo "Working in directory $THE_SCRIPT_DIR"

# this script does all the work. You do not run this script itself. It is
# included by for example, make_cb_puppy561

# ------------------------------------------------------------
# Technically you should not need to edit any lines below this
# ------------------------------------------------------------

usage="Turboloops make_codeblocks script
  Please specify the command properly...

  --hello        mandatory Safety against double click!
  --compile-wx   optional  Do not re-configure the wx
  --compile-cb   optional  Do not re-configure the codeblocks

    Build codeblocks only
      make_cb_xyz hello --compile-wx
   Build wx only
     make_cb_xyz --hello --compile-cb

   Rebuild everything
     make_cb_xyz --hello

if ! [ "$1" = "--hello" ]; then
  echo "$usage"


while [ "$1" ]; do
  if [ "$cmd" = "--compile-wx" ]; then
  if [ "$cmd" = "--compile-cb" ]; then
  if [ "$cmd" = "--clean-all" ]; then
    CleanCb="1"; CleanWx="1";
  if [ "$cmd" = "--clean-cb" ]; then
  if [ "$cmd" = "--clean-wx" ]; then

#echo "CleanCb=$CleanCb CleanWx=$CleanWx TheCbCmd=$TheCbCmd TheWxCmd=$TheWxCmd"

#if [ "$1" = "--compile-wx" ]; then
#  TheWxCmd="compile"
#  shift

#if [ "$1" = "--compile-cb" ]; then
#  TheCbCmd="compile"
#  shift


# Make the directories for wx
mkdir -p $wxOutputDir
mkdir -p $wxBuildDir
cd $wxBuildDir

if [ "$PuppyIs64Bit" = "1" ]; then
  x64Flags=CFLAGS="-fPIC" CXXFLAGS="-fPIC"

echo "The x64Flags are $x64Flags"
echo "The WxCmd is $TheWxCmd"
echo "The CbCmd is $TheCbCmd"

# --enable-monolithic

if [ "$CleanWx" = "1" ]; then
  make clean
if [ "$TheWxCmd" = "build" ]; then
  echo "Configuring wx in `pwd` ..."
  ../configure --prefix=$wxOutputDir --enable-unicode --enable-xrc --without-opengl $x64Flags
  make clean
make install

echo "Finished the wxWidgets compiling..."

# Put dir on path where is wx-config
export PATH=$wxOutputDir/bin:$PATH

# Add wxPrefixPath/lib to /etc/ just cheat and put it in variable)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$wxOutputDir/lib

# run ldconfig
#source /etc/profile

export ACLOCAL_FLAGS="-I $wxOutputDir/share/aclocal"

mkdir -p $cbOutputDir

# Make a symlink to the output directory in opt
cd /opt
rm $cbBuildName
ln -svf $cbOutputDir $cbBuildName

# Rename the output directory, now the compiler will put files in opt but
# actually is going to the proper place outside of Puppy Save files!

cd $cbOutputDir

echo > Install "# Install the codeblocks to opt/$cbBuildName !"
echo >> Install "THE_SCRIPT_DIR=\"\`echo \"\${0}\" | sed 's%/[^/][^/]*$%%'\`/\""
echo >> Install "if [ \"\${THE_SCRIPT_DIR}\" = \"./\" ]; then"
echo >> Install "  THE_SCRIPT_DIR=\"\`pwd\`\""
echo >> Install "fi"
echo >> Install "cd /opt"
echo >> Install "rm $cbBuildName"
echo >> Install "ln -svf \$THE_SCRIPT_DIR $cbBuildName"
echo >> Install "echo \"You can now use Codeblocks!\""

echo > Readme.txt "Codeblocks built for Puppy Linux by Turboloops -"
echo >> Readme.txt "--------------------------------------------------------"
echo >> Readme.txt "Each time you move this folder, just double click the script Install"
echo >> Readme.txt "and it will install it for you..."
echo >> Readme.txt "This build is not like Windows! It will look for libraries in"
echo >> Readme.txt "/opt/$cbBuildName and therefore you need to create the"
echo >> Readme.txt "symlink to this directory in /opt so that it works properly."
echo >> Readme.txt "If the Install script does not work then create the symlink yourself"
echo >> Readme.txt "but make sure the name of the symlink is $cbBuildName"

# Now return to where it was
cd $thePwd


# Here are the plugin names - Specify -TheName after the all to not do one and just comment out
# the entire line to not build any!
#Plugin names are: AutoVersioning, BrowseTracker,byogames,Cccc,CppCheck,cbkoders,codesnippets,
#             codestat, copystrings, Cscope, DoxyBlocks, dragscroll, EditorConfig, EditorTweaks, envvars,
#             FileManager, headerfixup, help, hexeditor, incsearch, keybinder, libfinder, MouseSap,
#             NassiShneiderman, profiler, regex, ReopenEditor, exporter, symtab, ThreadSearch,
#             ToolsPlus, Valgrind, wxsmith, wxsmithcontrib,wxsmithaui
# The plugins that are excluded here require libs, if you hve them then just change the line
if [ "$PuppyIs64Bit" = "1" ]; then

# Build the codeblocks now
cd $cbPath
if [ "$CleanCb" = "1" ]; then
  make clean
if [ "$TheCbCmd" = "build" ]; then
  echo "Configuring cb..."
  ./configure --with-wx-config=$wxOutputDir/bin/wx-config --prefix=$cbOutputDir $MyPlugins
  make clean
make install

# And now copy the wxWidgets dll files into your codeblocks folder, this
# is so the codeblocks can just run anywhere without needing wxwidgets to
# be installed.
cp $wxOutputDir/lib/lib* $cbOutputDir/lib

# Finally set the variables back and run ldconfig again, I am not sure
# if this is needed but it should keep the system clean? I mean I built
# a wrong version of wx before and then the link was always going to that
# version so maybe this will prevent that from happening.
#export PATH=$savePATH
#source /etc/profile

No comments:

Post a Comment