Author Topic: Newby Guide to Compiling (and Editing) With Code::Blocks  (Read 8343 times)

Offline Flare

  • Survivor
  • ***
  • Posts: 442
  • Scumming for the good of mankind
    • View Profile
Newby Guide to Compiling (and Editing) With Code::Blocks
« on: May 05, 2013, 06:19:29 AM »
Prior to beginning. Do note that melee.json, ranged.json, instruments.json, and recipes.json are accessible in cataclysm/data/raw folder. Once you compile the game, whatever is in the raw folder will be reloaded by the executable, meaning you will not have to fiddle with itemdefs if your stuff is in any of these four files. This is quite important as compiling takes a long time on older computers and makes the computer slow down to a crawl while it's at it.

To compile you need two things.

1. The code itself.
2. A program to run a special file in said code that instructs the program on how to compile the files.

After acquiring these two things,

3. You will need to compile it.



1a. The source code can be accessed from github. A link is available on the main page of the mode:

(click to show/hide)

1b. Upon clicking theat link, you will be brought to this github page:

(click to show/hide)

1c. Click the ZIP button in the red circle to commence a download of the code.

End of point 1. You more or less have the code.

===============================================================================================

2a. To download codeblocks, go to this site: http://www.codeblocks.org/downloads/26

2b. On that site, choose this installer:
(click to show/hide)

2c. Install the program, let the default settings guide you.

End of point 2. The program is now fully operational.


====================================================================================

Step 3 will compile the files. This means that if you want to make changes to the code or add stuff into it, you need to do it at this point, not after.

====================================================================================


3a. The code is in the zipped format, IE. it is compressed into a single file to allow for easy downloading. You need to unzip it:

(click to show/hide)

I have already extracted the file, the normal-looking file on top is the result of having extracted the file. The selected option in the right-clicked menu is the one you need to hit to get the normal-looking file.

3b. Go into the unzipped file and open this file:

(click to show/hide)

3c. Upon clicking it, this screen will pop up.

(click to show/hide)

3d. To compile, you need to right-click cataclysm on the left bar, and choose build.
(click to show/hide)

===============================================================

When the program finishes, it will look like this:
(click to show/hide)

Note, itemdefs will take a loooooooooooooong time to get through. As you can see (or maybe not depending on the resize), it takes me 35 minutes alone to compile it. Yours should be faster if you are not using a 5 year old unmodified laptop.

To play your modified game, you need to find the folder where the Code::Blocks file was and the executable should be in there.
(click to show/hide)

Offline Soron

  • Code Wrangler
  • Survivor
  • *****
  • Posts: 480
    • View Profile
Re: Newby Guide to Compiling (and Editing) With Code::Blocks
« Reply #1 on: May 05, 2013, 06:49:01 AM »
Cool, it's good to have a step-by-step guide for people :).

Just a note: we're steadily chipping away at itypedef.cpp (the massive item definition file). So, default compile times will hopefully be getting better over time, as we move stuff to data files, rather than having it hardcoded in the source.

Offline TheGrifter

  • Survivor
  • ***
  • Posts: 731
    • View Profile
Re: Newby Guide to Compiling (and Editing) With Code::Blocks
« Reply #2 on: June 16, 2013, 11:59:39 PM »
Thanks very much for this guide. Makes a lot of sense. Easy enough to understand.

Offline Natures Witness

  • Survivor
  • ***
  • Posts: 287
    • View Profile
Re: Newby Guide to Compiling (and Editing) With Code::Blocks
« Reply #3 on: August 02, 2013, 09:01:52 PM »
Would someone please update this for all the new gettext stuff that's now required to compile?  Specifically which EXACT files are needed?  I've been banging my head off the wall for weeks now with this and no luck :(. C'mon, I just wanna code again!  -sob-

Offline i2amroy

  • Contributor
  • Survivor
  • ****
  • Posts: 2757
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: Newby Guide to Compiling (and Editing) With Code::Blocks
« Reply #4 on: August 02, 2013, 10:04:48 PM »
Would someone please update this for all the new gettext stuff that's now required to compile?  Specifically which EXACT files are needed?  I've been banging my head off the wall for weeks now with this and no luck :(. C'mon, I just wanna code again!  -sob-
On that note if anybody actually knows a way to get it to work feel free to post here and we'll update it into the OP. Right now none of the devs are actually using code::blocks AFAIK, so it might take a while to be updated elsewise.

Offline GalenEvil

  • NPC
  • **
  • Posts: 240
  • Freelance Programmer
    • View Profile
    • Portfolio Page!
Re: Newby Guide to Compiling (and Editing) With Code::Blocks
« Reply #5 on: August 03, 2013, 02:20:45 AM »
*Note, copypasted this from my reply in this thread

For Code::Blocks Compiling

Here is what I have setup:
* In Settings>Compiler>Search Directories
--Compiler:
--++ C:\GnuWin32\include
--++ C:\GnuWin32\share\gettext\intl

--Linker:
--++ C:\GnuWin32\lib
--++ C:\Users\Galen\Libraries\GetText\lib

* In Project>Build options>Linker Settings (Cataclysm)
-- Other Linker Settings:
"-Wl,-stack,12000000,-subsystem,windows
-static -lgdi32 -llibintl -llibiconv"

I also have "libiconv2.dll" and "libintl3.dll" in the project's root directory.

May be a little overkill, but it works and I don't care for now as long as it works :D

url for "libiconv" installer : http://superb-dca2.dl.sourceforge.net/project/gnuwin32/libiconv/1.9.2-1/libiconv-1.9.2-1.exe
url for "libintl" installer : http://hivelocity.dl.sourceforge.net/project/gnuwin32/libintl/0.14.4/libintl-0.14.4.exe
url for GetText runtime: http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-1_win32.zip
url for GetText runtime-dev: http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime-dev_0.18.1.1-1_win32.zip

Hope these help :D
If you are on a non-Linux machine and wish to check out some of my projects: Portfolio!
Sorry to Linux users, Unity3D's webplayers do not work on Linux as far as I know.

Offline Jericoshost

  • Zombie Food
  • *
  • Posts: 95
    • View Profile
Re: Newby Guide to Compiling (and Editing) With Code::Blocks
« Reply #6 on: August 03, 2013, 07:22:24 AM »
I have a bit of a newbie question here...
What exactly is compiling for?
and what does it do?


Offline GalenEvil

  • NPC
  • **
  • Posts: 240
  • Freelance Programmer
    • View Profile
    • Portfolio Page!
Re: Newby Guide to Compiling (and Editing) With Code::Blocks
« Reply #7 on: August 03, 2013, 07:54:27 AM »
@Jericoshost: It's so you can take the source from the github repo and make your own version of the game. It also helps if you want to contribute as you will be able to tweak and test changes easily without flying blind and just hoping what you type will compile. Compiling, specifically, is turning the source code (.cpp and .h files) into the executable to be run. I am sure someone will come around and give a better answer (hoping for it in fact) but for now I hope the explanation works okay :)
If you are on a non-Linux machine and wish to check out some of my projects: Portfolio!
Sorry to Linux users, Unity3D's webplayers do not work on Linux as far as I know.

Offline Jericoshost

  • Zombie Food
  • *
  • Posts: 95
    • View Profile
Re: Newby Guide to Compiling (and Editing) With Code::Blocks
« Reply #8 on: August 04, 2013, 03:51:49 AM »
Ok I think I get it, thanks.

Offline The13thRonin

  • Zombie Food
  • *
  • Posts: 21
    • View Profile
Re: Newby Guide to Compiling (and Editing) With Code::Blocks
« Reply #9 on: October 14, 2013, 10:12:26 PM »
This doesn't work with Tilesets?

Offline ChunkOfMeat

  • Zombie Food
  • *
  • Posts: 73
    • View Profile
« Last Edit: February 11, 2014, 11:59:11 AM by ChunkOfMeat »

Offline newisle

  • Zombie Food
  • *
  • Posts: 72
    • View Profile
    • Emulators in Silence
Re: Newby Guide to Compiling (and Editing) With Code::Blocks
« Reply #11 on: August 05, 2014, 05:02:22 AM »
THX!! I build my first CDDA with Code::Blocks!! :D

but I found the cdda build from C::B  hasn't the i18n support :( anyone could help me?? many many thx!!!

Offline mightyagrippa

  • Zombie Food
  • *
  • Posts: 9
    • View Profile
Re: Newby Guide to Compiling (and Editing) With Code::Blocks
« Reply #12 on: August 07, 2015, 11:30:41 PM »
Very helpful guide, thank you! Only problem is that the GCC 4.7.1 compiler doesn't work with Cataclysm anymore per https://github.com/CleverRaven/Cataclysm-DDA/issues/12591.

Easily fixable by using a 4.8.x compiler like the one that comes with codeblocks-13.12mingw-setup-TDM-GCC-481.exe at the moment.

Edit: Noooope still getting an error. Guess I'm trying drbig's guide to getting most recent GCC in COMPILING.md
« Last Edit: August 09, 2015, 02:30:49 AM by mightyagrippa »

Offline Random_dragon

  • Survivor
  • ***
  • Posts: 6298
  • Psycho bored dragon.
    • View Profile
Re: Newby Guide to Compiling (and Editing) With Code::Blocks
« Reply #13 on: November 01, 2015, 04:48:10 PM »
Hmm. Will muck about with this soon.

One small question. If the source directory I use is my local copy of my Github repository, I'm assuming it will eat it and require I re-download the whole folder again?

EDIT: Nope. Will apparently have to find a working version of GCC, since it didn't like the one that came with the installer. Is it just me, or does the very CONCEPT of compiling hate me?

(click to show/hide)
« Last Edit: November 01, 2015, 05:12:19 PM by Random_dragon »

Offline Godworrior

  • Zombie Food
  • *
  • Posts: 9
    • View Profile
Re: Newby Guide to Compiling (and Editing) With Code::Blocks
« Reply #14 on: November 17, 2015, 10:50:34 PM »
I feel like I should note that you can significantly decrease build time by setting the number of precesses the compiler can use for building, to the number of cores your CPU has. I went from 15 minutes clean build time to 3. When going from 1 to 8 cores. :D

To do this; in Code::Blocks, go to Settings->Compiler...->Global compiler settings->build options. Then set the 'Number of processes for parallel builds' to the number of cores you have (I have 8).