[Sub] How to use GPC with CodeBlocks

Posted By: Rackscha

[Sub] How to use GPC with CodeBlocks - 01/16/12 17:44

Hello,
Here is a short tutorial on how to use my GenesisPrecompiler with CodeBlocks.

First you need CodeBlocks:
CodeBlocks.org
Get the most recent version of GPC:
GPC FormThread

Before we start with Codeblocks: unrar GPC and copy it into a folder like GenesisPrecompiler. MAke shure you create a subfolder called 'bin'. There you have to copy the GPCC.exe(hwy we have to copy it into a subdirectory? i'll explain later).

Now start codeblocks.
CodeBlocks features a wide support for most common compilers. GCC aims to be compatible with the GCC settings, so well create our own GCC config and replace it with GPCC.

On the mainmenu select settings->Compiler and debugger...
Here you select the GNU GCC Compiler from the top dropbox(if it isnt already selected).
Press the button COPY and enter a new name.(i.e. "GenesisPreCompiler").
After creating this new Setting, select it(if not selected) and go to the tab "ToolChain executables".
For "Compilers installation directory" press the "..." button next to the edit. And now we have the reason for the bin Subfolder. We have to select the folder, where the bin folder is located in and NOT the bin folder itself.
After selecting the directory, we have to replace some of the tools below:

for C-Compiler and C++-Compiler, replace the exe with "GPCC.exe".
For the linker, do the same and write "GPCC.exe".
You can leave the rest as it is.

BasicSetup is ready. Now we need to do the following:

In the MainMenu goto Project-> Set programs arguments
and for the programms arguments, add "-run"

Now we can create our first testfiles.

In the MainMenu goto File->New Project->Empty project.
Follow the wizzard(add filename etc).
The second page of the wizard is the Compileroption. From the top dropbox select the GenesisPrecompiler. You may uncheck "Create debug option" since its useless atm.

Add a new file to your project(File->New-> Empty File) and save it for example as "Main.cxx".

add this code:
Code:
#include<Acknex.h>;
#include<TestClass.cxx>;

void main()
{
    STRING* LNumber = str_create("");
    CTestClass* LClass;
    LClass = _CTestClass();
    while(key_enter == 0)
    {
        draw_text(LClass.ClassName, 20, 20, vector(100, 100, 100));
        draw_text(LClass.ClassParentName, 20, 80, vector(100, 100, 100));
        str_for_int(LNumber, LClass.GetNumber(LClass));
        draw_text(LNumber, 20, 100, vector(100, 100, 100));
        wait(1);
    }
    delete(LClass);
    ptr_remove(LNumber);
}




add another file to the project, save it as TestClass.cxx and insert this code:
Code:
#include<BaseClass.cxx>;

class CTestClass: public CBaseClass
{
private:
	int FX;
public:
    int GetNumber();
    CTestClass();
};


int CTestClass::GetNumber()
{
    return(This.FX);
}

 CTestClass::CTestClass()
{
    This.FX = 34;
}



Make shure BaseClass.cxx is in your projectfolder. You dont have to include Baseclass.cxx or derive a class from CBaseClass since they are always used implicitly. But for this turorial its better.
In the toolbar, hit the Build button. If it runs fine, click the run button.
If it does not build, take a look into the error messages.

If you have any questions, dont hestinate and ask me laugh

Greetings
Rackscha
© 2024 lite-C Forums