Skip to content

Codex on Code::Blocks

This tutorial covers how to dynamically link Codex in your projects. You can still statically link it, but I recommend the dynamic way.

Setup your program

  • Create a project
    Create a new “Console application” or “Empty project” using the GCC compiler.
  • Configure the build options
    • Open the project build options. On the left panel, select the project to apply the next options for all targets (debug and release). Alternatively you can set different options in each target (for example to use codex debug and release versions in your corresponding targets).
      Go to the Linker settings tab. In Other linker options write “-lcodex” (-l directive tells linker to search for the library). Note: if you want to use the Codex debug version for your debug configuration, use the “-d” sufix (“-lcodex-d”).
      Screenshot of the dialog box for setting up the linker options
    • Select the Search directories tab.
      - On Compiler add “<Codex>\include“.
      - On Linker add “<Codex>\lib“.
      Where <Codex> stands for your Codex instalation directory. This will tell where Codex header files and libraries are.
      Screenshot of the dialog box for setting up the compiler search directoriesScreenshot of the dialog box for setting up the linker search directories
  • Build
    All configured, create a dummy code that uses Codex and build it, just to see if everything goes fine. Here’s a dummy code which does nothing:If everything is fine then you’re ready to code your host application. If gives errors, make sure that the build options are correct for the target that you’re trying to build.

    #include <Codex/Default.hpp>
    #include <iostream>
    
    int main(){
        cx::File inputFile("SomeFile.txt");
    
        std::cout << "Press any key to exit";
        std::cin.ignore(10000, '\n');
        return 0;
    }
  • Execute
    The binary files (executable) of your application won’t run without codex.dll (unless you have statically linked it) and zlib1.dll (for compression). Copy those dlls into the folder where your executable is generated (usually a bin folder on your project). The library codex.dll is at <Codex>\lib and the zlib1.dll is at <Codex>\extlibs\lib directory, where <Codex> stands for your Codex installation folder.

Tutorial Index