Installing GLUI using CodeBlocks on windows

Here is another way to installing GLUI on windows. Before going to install the glui, please ensure that the glut is installed properly.

  1. Download glui library from in the files section u will find the latest release version of glui.
  2. Extract the zip file somewhere in ur disk, Open Code::Blocks, Click File -> Import Projects -> MS Visual Studio Solution ..

    Importing the VS GLUI Project

    Importing the VS GLUI Project

  3. Then open the glui-2.36 directory (i use glui-2.36 version) under src directory u will find msvc directory, then open glui.sln file. Next, Click yes to convert the VS solution into Code::Block projects (All)

    Confirmation box

    Confirmation box

  4. Right click on _glui library project and select Activate project then build the library (the glui library will be build the static library, if u prefer with dynamic library than choose _gluidlllibrary)
    Activating the _gluilibrary project

    Activating the _gluilibrary project

    Compiling the glui library

    Compiling the glui library

  5. After building the library, the lib file (libglui32.a) will be stored in the msvc\lib directory
  6. Put the libglui32.a file into C:\Program Files\CodeBlocks\MinGW\lib directory
  7. while glui.h file into C:\Program Files\CodeBlocks\MinGW\include\GL directory
  8. Now try to compile glui example file which provided within the GLUI main project
  9. Activate the example 2 by right clicking on the projects and select Activate project, then try to compile the project.
    Activating Example 2 Project

    Activating Example 2 Project

    Compiling Example 2 Project

    Compiling Example 2 Project

    If there are some errors occurred during compilation, i.e,

    Release\example\example2.o:example2.cpp:(.text+0x107): undefined reference to `__glutInitWithExit'
    Release\example\example2.o:example2.cpp:(.text+0x113): undefined reference to `glutInitDisplayMode'
    Release\example\example2.o:example2.cpp:(.text+0x127): undefined reference to `glutInitWindowPosition'
    Release\example\example2.o:example2.cpp:(.text+0x13b): undefined reference to `glutInitWindowSize'
    Release\example\example2.o:example2.cpp:(.text+0x14f): undefined reference to `__glutCreateWindowWithExit'
    Release\example\example2.o:example2.cpp:(.text+0x160): undefined reference to `glutDisplayFunc'
    Release\example\example2.o:example2.cpp:(.text+0x16c): undefined reference to `glutReshapeFunc'
    Release\example\example2.o:example2.cpp:(.text+0x178): undefined reference to `glutKeyboardFunc'
    Release\example\example2.o:example2.cpp:(.text+0x184): undefined reference to `glutMotionFunc'
    Release\example\example2.o:example2.cpp:(.text+0x190): undefined reference to `glutMouseFunc'
    Release\example\example2.o:example2.cpp:(.text+0x1d0): undefined reference to `_imp__glEnable'
    Release\example\example2.o:example2.cpp:(.text+0x200): undefined reference to `_imp__glLightfv'
    Release\example\example2.o:example2.cpp:(.text+0x274): undefined reference to `GLUI_Master'
    Release\example\example2.o:example2.cpp:(.text+0x279): undefined reference to `GLUI_Master_Object::create_glui(char const*, long, int, int)'
    Release\example\example2.o:example2.cpp:(.text+0x2ad): undefined reference to `GLUI_StaticText::GLUI_StaticText(GLUI_Node*, char const*)'
    Release\example\example2.o:example2.cpp:(.text+0x2e1): undefined reference to `GLUI_Separator::GLUI_Separator(GLUI_Node*)'
    Release\example\example2.o:example2.cpp:(.text+0x33d): undefined reference to `GLUI_Checkbox::GLUI_Checkbox(GLUI_Node*, char const*, int*, int, GLUI_CB)'
    Release\example\example2.o:example2.cpp:(.text+0x39e): undefined reference to `GLUI_Spinner::GLUI_Spinner(GLUI_Node*, char const*, int*, int, GLUI_CB)'
    Release\example\example2.o:example2.cpp:(.text+0x3cf): undefined reference to `GLUI_Spinner::set_int_limits(int, int, int)'
    Release\example\example2.o:example2.cpp:(.text+0x41f): undefined reference to `GLUI_EditText::GLUI_EditText(GLUI_Node*, char const*, std::string&, int, GLUI_CB)'
    Release\example\example2.o:example2.cpp:(.text+0x468): undefined reference to `GLUI_Panel::GLUI_Panel(GLUI_Node*, char const*, int)'
    Release\example\example2.o:example2.cpp:(.text+0x4bc): undefined reference to `GLUI_RadioGroup::GLUI_RadioGroup(GLUI_Node*, int*, int, GLUI_CB)'
    Release\example\example2.o:example2.cpp:(.text+0x502): undefined reference to `GLUI_RadioButton::GLUI_RadioButton(GLUI_RadioGroup*, char const*)'
    Release\example\example2.o:example2.cpp:(.text+0x53f): undefined reference to `GLUI_RadioButton::GLUI_RadioButton(GLUI_RadioGroup*, char const*)'
    Release\example\example2.o:example2.cpp:(.text+0x57c): undefined reference to `GLUI_RadioButton::GLUI_RadioButton(GLUI_RadioGroup*, char const*)'
    Release\example\example2.o:example2.cpp:(.text+0x5d0): undefined reference to `GLUI_Button::GLUI_Button(GLUI_Node*, char const*, int, GLUI_CB)'
    Release\example\example2.o:example2.cpp:(.text+0x5ed): undefined reference to `GLUI::set_main_gfx_window(int)'
    Release\example\example2.o:example2.cpp:(.text+0x5fc): undefined reference to `GLUI_Master'
    Release\example\example2.o:example2.cpp:(.text+0x601): undefined reference to `GLUI_Master_Object::set_glutIdleFunc(void (*)())'
    Release\example\example2.o:example2.cpp:(.text+0x606): undefined reference to `glutMainLoop'
    Release\example\example2.o:example2.cpp:(.text+0x710): undefined reference to `_imp__glViewport'
    Release\example\example2.o:example2.cpp:(.text+0x79b): undefined reference to `GLUI_Master'
    Release\example\example2.o:example2.cpp:(.text+0x7a0): undefined reference to `GLUI_Master_Object::sync_live_all()'
    Release\example\example2.o:example2.cpp:(.text+0x7d1): undefined reference to `GLUI_Master'
    Release\example\example2.o:example2.cpp:(.text+0x7d6): undefined reference to `GLUI_Master_Object::sync_live_all()'
    Release\example\example2.o:example2.cpp:(.text+0x8ca): undefined reference to `_imp__glClearColor'
    Release\example\example2.o:example2.cpp:(.text+0x8d7): undefined reference to `_imp__glClear'
    Release\example\example2.o:example2.cpp:(.text+0x8e4): undefined reference to `_imp__glMatrixMode'
    Release\example\example2.o:example2.cpp:(.text+0x8ec): undefined reference to `_imp__glLoadIdentity'
    Release\example\example2.o:example2.cpp:(.text+0x945): undefined reference to `_imp__glFrustum'
    Release\example\example2.o:example2.cpp:(.text+0x96d): undefined reference to `_imp__glTranslatef'
    Release\example\example2.o:example2.cpp:(.text+0x993): undefined reference to `_imp__glRotatef'
    Release\example\example2.o:example2.cpp:(.text+0x9ef): undefined reference to `glutWireSphere'
    Release\example\example2.o:example2.cpp:(.text+0xa13): undefined reference to `_imp__glDisable'
    Release\example\example2.o:example2.cpp:(.text+0xa63): undefined reference to `_imp__gluOrtho2D'
    Release\example\example2.o:example2.cpp:(.text+0xa8b): undefined reference to `_imp__glColor3ub'
    Release\example\example2.o:example2.cpp:(.text+0xaa0): undefined reference to `_imp__glRasterPos2i'
    Release\example\example2.o:example2.cpp:(.text+0xae0): undefined reference to `glutBitmapCharacter'
    Release\example\example2.o:example2.cpp:(.text+0xafb): undefined reference to `_imp__glEnable'
    Release\example\example2.o:example2.cpp:(.text+0xb29): undefined reference to `glutSolidSphere'
    Process terminated with status 1 (0 minutes, 0 seconds)
    50 errors, 0 warnings

    then, the glui lib must be rebuilt

  10. Reactivate the _gluilibrary project and open glui.h within the project (there are 2 glui.h inside the project and C:\Program Files\CodeBlocks\MinGW\include\GL directory)
  11. Edit the glui.h and insert
    #include <windows.h> ;

    before #include <cstdlib> line.

    Recompiling the _gluilibrary project

    Rebuild the _gluilibrary project

    Rebuild the _gluilibrary project



  12. Don’t forget to copy the new glui.h file into C:\Program Files\CodeBlocks\MinGW\include\GL
  13. Reactive the example 2 project, then click Project -> Build Options …

    Example 2 project option

    Example 2 project option

  14. On the top left of the dialog window, ensure that Release Win32 is selected. Then, click Link Settings (1) -> Add -> On Add library dialog window click […] -> Select No (2).
    Add glui lib into example 2 project

    Add glui lib into example 2 project

    Adding glui library

    Adding glui library

  15. Move the glui library to the top of the list by clicking arrow button at the right of the list

    Put the glui library on the top of the list

    Put the glui library on the top of the list

  16. Build and run the Example 2 project

    Final Result

    Final Result


23 thoughts on “Installing GLUI using CodeBlocks on windows

  1. Hello,
    When I tried to build Example 2 (tried some of the others, too) it gives me this error: “ld.exe | cannot find -lglut32”. So some help would be welcomed.

    (This is Step 9 of this Guide.)

    • At the build options menu, on the left side, you’ll see Release Win32, Debug Win32, etc. Choose Debug Win32 instead of Release Win32 =)

    • I managed to run them by changing glut32d to freeglut and glui32d to libglui32. It appears that the normal libraries (not specifically made for debugging) also do the job.

  2. Oh, forgot to tell you that in 64-bit Windows the CodeBlocks is usually in “Program Files (x86)”.

    Like: C:\Program Files (x86)\CodeBlocks\…

    You probably should mention it as a Note in step 6, just in case someone forgets to look in Program Files (x86).

    • It doesn’t matter if the Windows is XP or not. Only if it is 64-bit or not. Mine is 64-bit XP and yours is (or at least it appears to me to be) 32-bit XP.

      Another possibility is that you’ve changed the download location for CodeBlocks.

  3. Checked the other Examples:
    – Example 4 is the same as Example 3. Also in Build options they have first Debug Win32 and only then Release Win32, unlike in Examples 1 and 2 where it’s vice versa and are working.
    – Example 5 and 6 also don’t work. They don’t have anything in any of the Releases, only in Debug parts, so maybe that’s why they don’t work. Anything related to gl or glui is treated as error (probably because the Linkers are empty). Gonna fill them and check if they work.

  4. By the way, I found something peculiar:

    When today I run Examples 1 and 2 they were working but the Linker options for them were the same before I edited them yesterday, i.e. ‘glut32’ instead of ‘freeglut’ and no c:\long-path\libglui32.a

  5. Examples 5 and 6 work after you add the necessary linkers in Release:
    freeglut (or glut32)

    P.S. After rebuilding Example 1 and 2 they stop working and I had to redo the linking.

  6. Just went through the first example. Few questions follow:

    In your code in the first example you have the following code:

    void myGlutIdle( void )
    /* According to the GLUT specification, the current window is
    undefined during an idle callback. So we need to explicitly change
    it if necessary */
    if ( glutGetWindow() != main_window )

    } – in the description there is: “If the window you want to post a redisplay on is not already current (and you do not require it to be immediately made current), using glutPostWindowRedisplay is more efficient that calling glutSetWindow to the desired window and then calling glutPostRedisplay.”

    Did you simply not know that or you coded it this way on purpose? And why glutPostRedisplay() is outside the if()? Also what purpose does serve myGlutIdle function?

  7. And what does:

    void myGlutMenu( int value )
    myGlutKeyboard( value, 0, 0 );

    actually do? This function isn’t called anywhere in Example2.cpp

  8. Yet another question:
    In Example 1 you use glFrustum in myGlutReshape(), but in Example 2 and 3 you use it in myGlutDisplay(). Why is that? I see that it’s not working if it’s in the Reshape func but I don’t understand why.

  9. Also, in Examples 3 and 4 (haven’t checked the rest yet) you have a Live Variable segments2 which you don’t use at all in the code.

  10. And what are these callback IDs (and why their values are always the ones specified):

    /********** User IDs for callbacks ********/
    #define LIGHT0_ENABLED_ID 200
    #define LIGHT1_ENABLED_ID 201
    #define LIGHT0_INTENSITY_ID 250
    #define LIGHT1_INTENSITY_ID 251

    I tried to Google it but nothing interesting came up (usually only the code of the examples). :(

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s