[solved] Set up error with Code::blocks

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
rubenwardy
Posts: 91
Joined: Mon Mar 05, 2012 4:51 pm
Location: Bristol, UK
Contact:

[solved] Set up error with Code::blocks

Post by rubenwardy »

I have recently moved from VC++ to Code::Blocks.

In the ide, it gets up to "device->run()"

Just normal exe running it gets to start scene

The program crashes with "Program has stopped working. Windows is trying to find a solution to this program".

Code: Select all

#include <iostream>
#include <irrlicht.h>
 
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
int main(){
 
    IrrlichtDevice *device =createDevice(EDT_OPENGL, dimension2d<u32>(512, 384), 16,
            false, false, false, 0);
 
   if (!device)
        return 0;
 
    IVideoDriver* driver = device->getVideoDriver();
 
    ISceneManager* smgr = device->getSceneManager();
 
    IGUIEnvironment* guienv = device->getGUIEnvironment();
 
    if (!driver)
        return 0;
 
    if (!smgr)
        return 0;
 
    if (!guienv)
        return 0;
 
    device->setWindowCaption(L"Title to set");
 
    while(device->run())
    {
        driver->beginScene(true, true, SColor(255,100,101,140));
 
        smgr->drawAll();
        guienv->drawAll();
 
        driver->endScene();
    }
    device->drop();
    return 0;
}
In the "Build Options" menu i have done the following things.

"Linker Settings" Added a link to irrlicht.lib

"Search Directories" Added "include" and the folder .lib is in to each of the sub-sections

I have copied "irrlicht.dll" to the run directory.
Last edited by rubenwardy on Mon Aug 13, 2012 10:37 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Set up error with Code::blocks

Post by CuteAlien »

Any errors/warnings/messages in the console window?
Did you try running the examples first? They have a c::b project file (in the example folder) which should already have all the correct settings. So test if that works first.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
rubenwardy
Posts: 91
Joined: Mon Mar 05, 2012 4:51 pm
Location: Bristol, UK
Contact:

Re: Set up error with Code::blocks

Post by rubenwardy »

No error messages, i did not know there was a set up in the examples, will try it now
Violence
Posts: 10
Joined: Mon Aug 13, 2012 11:32 am

Re: Set up error with Code::blocks

Post by Violence »

I think you need to build Irrlicht with C::B first (if you use MinGW ofc) and link your project to libIrrlicht.a
rubenwardy
Posts: 91
Joined: Mon Mar 05, 2012 4:51 pm
Location: Bristol, UK
Contact:

Re: Set up error with Code::blocks

Post by rubenwardy »

Compiling Example 01 - Hello World comes up with:

file: ld message: cannot find -1irrlicht

EDIT:

I corrected the linked libraries from "irrlicht" to "../../lib/irrlicht.lib" and it compiled properly, but the same error happened

The text of the irricht window is "?????>CA?A?>?>" --Proberly corrupted
rubenwardy
Posts: 91
Joined: Mon Mar 05, 2012 4:51 pm
Location: Bristol, UK
Contact:

Re: Set up error with Code::blocks

Post by rubenwardy »

Violence wrote:I think you need to build Irrlicht with C::B first (if you use MinGW ofc) and link your project to libIrrlicht.a
What is MinGW?
Violence
Posts: 10
Joined: Mon Aug 13, 2012 11:32 am

Re: Set up error with Code::blocks

Post by Violence »

The gcc compiler which ships by default with Code::Blocks (codeblocks-10.05mingw-setup.exe)
rubenwardy
Posts: 91
Joined: Mon Mar 05, 2012 4:51 pm
Location: Bristol, UK
Contact:

Re: Set up error with Code::blocks

Post by rubenwardy »

I am using a portable version (is not installed, got in a zip), and the "GNU GCC Compiler"
Violence
Posts: 10
Joined: Mon Aug 13, 2012 11:32 am

Re: Set up error with Code::blocks

Post by Violence »

Then try to build Irrlicht from source in C::B. You should get \bin\Win32-gcc\Irrlicht.dll and \lib\Win32-gcc\libIrrlicht.dll.a (or libIrrlicht.a). Use them in your project, they must work proper. Try it, you wont lose anything ;)
rubenwardy
Posts: 91
Joined: Mon Mar 05, 2012 4:51 pm
Location: Bristol, UK
Contact:

Re: Set up error with Code::blocks

Post by rubenwardy »

Thank you for your help :)
rubenwardy
Posts: 91
Joined: Mon Mar 05, 2012 4:51 pm
Location: Bristol, UK
Contact:

Re: Set up error with Code::blocks

Post by rubenwardy »

Thank you so much! It works :) !!!!!
Violence
Posts: 10
Joined: Mon Aug 13, 2012 11:32 am

Re: [solved] Set up error with Code::blocks

Post by Violence »

I glad it worked :)
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Set up error with Code::blocks

Post by CuteAlien »

rubenwardy wrote: file: ld message: cannot find -1irrlicht

EDIT:

I corrected the linked libraries from "irrlicht" to "../../lib/irrlicht.lib" and it compiled properly, but the same error happened
About that... you should use the library name, aka -lIrrlicht (not -1irrlicht).
And the path where it searchs for the library is then set in the linker path options.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply