Results 1 to 5 of 5

Thread: ClanLib and Code::Blocks

  1. #1

    Default ClanLib and Code::Blocks


    I've been slamming my head against the wall because I have been trying to get Clanlib to work for a long time with code::blocks. Needless to say, it is not successful. I still can't figure out how to run the simple test program
    #include <ClanLib/gl.h>
    #include <ClanLib/core.h>
    #include <ClanLib/application.h>
    #include <ClanLib/display.h>
    class MyApp : public CL_ClanApplication
        virtual int main(int argc, char **argv)
            // Create a console window for text-output if not available
            // Use printf or cout to display some text in your program
            CL_ConsoleWindow console("Console");
                // Initialize ClanLib base components
                CL_SetupCore setup_core;
                // Initialize the ClanLib display component
                CL_SetupDisplay setup_display;
                // Initialize the ClanLib GL component
                CL_SetupGL setup_gl;
                // Create a display window
                CL_DisplayWindow window("ClanLib application", 640, 480);
                // Run until someone presses escape
                while (!CL_Keyboard::get_keycode(CL_KEY_ESCAPE))
                    // Clear the display in a dark blue nuance
                    // The four arguments are red, green, blue and alpha (defaults to 255)
                    // All color nuances in ClanLib are measured in the interval 0->255
                    CL_Display::clear(CL_Color(0, 0, 50));
                    // Flip the display (using a double-buffer),
                    // showing on the screen what we have drawed
                    // since last call to flip()
                    // This call updates input and performs other "housekeeping"
                    // Call this each frame
                    // Also, gives the CPU a rest for 10 milliseconds to catch up
            // Catch any errors from ClanLib
            catch (CL_Error err)
                // Display the error message
                std::cout << err.message.c_str() << std::endl;
            // Display console close message and wait for a key
            return 0;
    using code:blocks. I can get it to compile, but to run it, it is hell...

    It uses the command

     xterm -e'LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH /usr/bin/cb_console_runner "/home/matt/game/Anything/bin/Debug/Anything" '
    to run the program, but then it gives the error
     error while loading shared libraries: cannot open shared object file: No such file or directory
    . I've tried running the binary by itself by cd into the bin directory and calling it directly making sure that /usr/local/lib is in LD_LIBRARY_PATH and I can't do it either, it says
    You need a create a display target first.
    whereas when I compile it myself and run it it runs fine!

    this is very very very frustrating please any help is appreciated, especially if you got stuff to compile and run with code::blocks

  2. #2
    ClanLib Developer
    Join Date
    May 2007


    I have never heard of Code::Blocks, it looks like a good ide

    Anyway, did you run ldconfig after "make", "make install" of ClanLib?

  3. #3


    thanks for the reply rombust, but I am going to be switching from code::blocks to kdevelop. I think code::blocks is too bugy at the moment, the environment variable setting options do not work at all. My original IDE choice was Eclipse with CDT but the auto-completion feature of CDT is painfully slow, sometimes freezing the IDE for about 15-30 seconds. I am familiar with exlipse because throughout school this is the IDE of choice for all my Comp Sci classes as we were taught Java first. Since Im starting out with ClanLib, I know that auto-completion of code will be very helpful, so I decided to switch to an IDE with more native support. Code::blocks was one of them and it looked good. But I had way too many problems. So then I tired Anjuta IDE, which works great, but auto completion is too primitive only indexing previously written (by me) code. Last, KDevelop I tried in desperation and it works great after a few hours playing around with it and setting it up, it looks like Im ready to go.

    BTW what does ldconfig do?

  4. #4
    ClanLib Developer
    Join Date
    May 2007


    Thanks for the info.

    It is possible Clanlib installation automatically runs ldconfig, i have not checked.

    Quote from ldconfig man page:
    ldconfig creates, updates, and removes the necessary links and cache (for use by the run-time linker, to the most recent shared libraries found in the directories specified on the command line, in the file /etc/, and in the trusted directories (/usr/lib and /lib). ldcon‐fig checks the header and file names of the libraries it encounters when determining which versions should have their links updated. ldconfig ignores symbolic links when scanning for libraries.

  5. #5



    I have just successfully compiled and run a ClanLib test program of mine in Code::Blocks.

    However, I got the problem at compile-time, not run-time. It might still help you... maybe you just weren't getting the error/warning (were you using -Wall ?).

    All I had to do, with my signal-related problems was go to the Project's Build Options, and have the linker link with the clanSignals library (and this is not needed with a regular makefile). I'm assuming the file the executable complains about exists, since you have no problems compiling yourself.

    I hope this might've been it. Maybe you can test it?

Similar Threads

  1. Code::Blocks
    By ART_Adventures in forum Official ClanLib SDK Forums
    Replies: 6
    Last Post: 01-14-2010, 12:00 AM
  2. [img] code in signatures or images
    By aGig in forum RTsoft Tavern
    Replies: 0
    Last Post: 01-31-2007, 02:52 AM
  3. Submit Code to Clanlib
    By ART_Adventures in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 09-26-2006, 10:25 PM
  4. registration code?
    By in forum RTsoft Tavern
    Replies: 4
    Last Post: 09-05-2004, 12:38 AM
  5. Source Code
    By Wavesphere in forum Dink Smallwood HD
    Replies: 4
    Last Post: 10-27-2002, 09:13 AM



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts