Compiling with Code::Blocks Linux
Introduction
Code::Blocks is a open-source IDE compared to Microsoft Visual Studio/Express.
The good thing about open-source is that you can use it also in any OS.
Before you can do this you need to have done Compiling with Linux otherwise you files probably are not ready yet for linux.
Creating a New Project
First, we must create the project in which we are going to work:
- Start Code::Blocks
- Close any open Workspaces
- Choose from the menu File->New->Project..
- From the New From template dialog choose Projects->Shared Library and click Go.
- A Shared Library dialog will start, click on Next.
- Click in the Project title entry and type a name for your project
- Check the Folder to creat a project in and make sure it's correct and press Next.
- In the next dialog choose as compiler:GNU GCC Compiler and make sure that Release is checked and not Debug unless you want that and click on Finish
Adding Files to the New Project
Before we can add new files t the project you first need to remove the 1 file that were created to the project so we got a emtpy project.
- Choose from the menu Project->Remove files..
- main.c should already be selected, press OK
- A new confirmation dialoog will start, press Yes
- The files main.c are still there you probably want to deleted them in an File Manager, so you don't accidently add them.
Now that we have our project and workspace, we need to add id's Kingpin Linux SDK source files to the project.
- Create a new folder in your project directory called "Source"
- Copy the Kingpin Linux SDK source files to this directory
- Under the menu Project->Add Files..
- Change to the source directory you just created
- Select all the *.c and *.h files from the Kingpin source (make sure you don't add main.cpp and main.h if you have not deleted them)
- and click Open.
Fixing the Compiler
There still some things missing from the compiler the Kingpin SDK. Kingpin needs some NavLib files otherwise it won't compile.
- menu Project->Build Options...
- Click on the Tab Linker settings
- In the Link libaries: add the 4times the following files including path:
- g_nav.o
- g_nav_cells.o
- g_nav_io.o
- g_nav_misc.o
Next you need to fix some Compiler flags still under
- menu Project->Build Options...
- Tab Compiler settings
- Turn on flag: Target x86 (32bit) [-m32]
- Turn on flag: Position Independent Code [-fPIC]
- Now it should compile 32bit atleast without any error.
To compile the .so with the correct name and the correct folder for example in game folder of Kingpin:
- menu Project->Properties...
- Click on the Tab Build Targets
- Output filename: bin\Release\gamei386.so
- and click OK
Download project file
Code::Blocks |