Irrlicht with MinGW Compiler

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
alexescamilla
Posts: 8
Joined: Sat Apr 19, 2014 9:51 pm

Irrlicht with MinGW Compiler

Post by alexescamilla »

ok so i am trying to compile irrlicht directly from a batch file use MinGW G++ compiler.

i can create my main.exe but when it runs nothing happens.
i dont even get errors.

can anyone help me figure out whats going on?
even if it is just to have the compiler tell me why its not loading would be awesome.
thanks a bunch

here is my main.cpp file

Code: Select all

#include <irrlicht.h>
 
using namespace irr;
 
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
int main()
{
    irr::IrrlichtDevice *device =
        createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
            false, false, false, 0);
 
    if (!device)
        return 1;
    
    device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
    
    irr::video::IVideoDriver* driver = device->getVideoDriver();
    irr::scene::ISceneManager* smgr = device->getSceneManager();
    irr::gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
    
    guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
        rect<s32>(10,10,260,22), true);
    
    irr::scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
    if (!mesh)
    {
        device->drop();
        return 1;
    }
    irr::scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
    
    if (node)
    {
        node->setMaterialFlag(EMF_LIGHTING, false);
        node->setMD2Animation(scene::EMAT_STAND);
        node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
    }
    
    smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
    
    while(device->run())
    {
    
    driver->beginScene(true, true, SColor(255,100,101,140));
 
        smgr->drawAll();
        guienv->drawAll();
 
        driver->endScene();
    }
    
    device->drop();
 
    return 0;
}
and this is my batch file

Code: Select all

cls
@echo off
 
g++ -c main.cpp -o main.exe -L C:\Users\alex\Desktop\irrlicht-1.8.1\irrlicht-1.8.1\lib\Win32-gcc -l C:\Users\alex\Desktop\irrlicht-1.8.1\irrlicht-1.8.1\lib\Win32-gcc\libIrrlicht.a -I C:\Users\alex\Desktop\irrlicht-1.8.1\irrlicht-1.8.1\include
pause
 
main
pause
compile+run.bat
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Irrlicht with MinGW Compiler

Post by CuteAlien »

Haven't used a .bat file in years - and I don't think using them for building would be a good idea. That's why makefiles exist. There's examples for Makesfile in the examples folder.
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
alexescamilla
Posts: 8
Joined: Sat Apr 19, 2014 9:51 pm

Re: Irrlicht with MinGW Compiler

Post by alexescamilla »

i dont understand the use of a makefile......
nor how to properly use it lol
i am used to using batch files for the simplicity
alexescamilla
Posts: 8
Joined: Sat Apr 19, 2014 9:51 pm

Re: Irrlicht with MinGW Compiler

Post by alexescamilla »

please keep in mind i am stuck using the command prompt to compile because most ides dont like my computer.
the only one i can get to remotely work properly is devc++ and it is no long supported by irrlicht or atleast the files needed are no long given.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Irrlicht with MinGW Compiler

Post by mongoose7 »

1. Why not use MSYS? You can compile Irrlicht with 'make win32'.
2. Don't double-click on a .bat file, open a command prompt. You will then see all the messages (when the app exits).
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Irrlicht with MinGW Compiler

Post by CuteAlien »

If you don't understand Makfiles start learning - knowing Makesfiles is worth it. Every serious coder will run into them over and over.

Using them is usually done by going in the folder where "Makefile" is in and typing: make
That will build the first target given in the Makefile.

As our makefiles in Irrlicht default to Linux you have to set another target for Windows, for example: make all_win32

I can't give you a full introduction now, but makefiles are a text-format that contains all the typical stuff you need for building an application or library. When you name it "Makefile" it will be used by default when you call make (you can also use other filenames and pass them to "make -f"). "make" is a tool that interprets the Makefiles.

Makefiles work by having targets. Like the "all_win32" above. You can have any number of targets in your makefile and it will create the one you pass when you call make (so "make all_win32" will create the target all_win32 which has to be in the Makefile). When users don't pass a target then the first one in the Makefile is used.

If you look at one of the Irrlicht makefiles you find all the targets by looking for names followed by a colon (like "clean:" which is a target to clean all files which were created). If there are some more names following after a target then those are further targets which will be called first (so targets work the same way as functions in other languages). So for example "clean: clean_linux clean_win32" means that if the users calls target "clean" that one will call "clean_linux" and "clean_win32" first.

And in the next lines after a target the commands follow. Each one always starting with a <tab>. No whitespace, real tab needed! And then just any command the shell knows. For example your g++ call.

Makefiles also have variables (all you need is: variable = somestuff). You use them like $(my_variable).

And some more features for comfort: Makefiles can access shell-variables and have some "if" commands.

About your .bat file - it works in theory - it's just not so comfortable. Your problem might be that -L and -l and so on should not have a whitespace. It's -Lmylibrary and not -L mylibrary (filenames can start with whitespaces - so those are not the same names).

And about IDE's. On Windows I'll recommend either code::blocks or VisualStudio (the express version is free of cost although not open-source).
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
alexescamilla
Posts: 8
Joined: Sat Apr 19, 2014 9:51 pm

Re: Irrlicht with MinGW Compiler

Post by alexescamilla »

did not know it was supported for irrlicht lol
alexescamilla
Posts: 8
Joined: Sat Apr 19, 2014 9:51 pm

Re: Irrlicht with MinGW Compiler

Post by alexescamilla »

ooooooo never had an issue with the white spaces before but ill give that a shot. i have tried code::blocks it just confuses me so bad lol
i have attempted to do stuff with visualstudio but when i go to compile it makes my screen go all wonky and if i dont restart my machine i will bluescreen after a short time.
thanks for the suggestions imma try to remove the whitespaces if that doesnt work ill try the makefile stuff.
although it still confuses. i will most likely look on google/youtube for any tutorials/references that explains them a bit more.
i will keep yall posted. thanks so much :)
alexescamilla
Posts: 8
Joined: Sat Apr 19, 2014 9:51 pm

Re: Irrlicht with MinGW Compiler

Post by alexescamilla »

ok so tested without whitespaces and then tested the make file.
the .bat runs and it compiles the could but it fails to actually create the window still.(still no errors in the code lol)
the make file how ever after i made a minor change in it export to main.exe or what ever as u said above it gives me a single error.
easiest way i can show it is by picture.
my question is do i need to move the bin folder over in order for it to work?
that is what it seems the error is telling me or am i just reading it wrong? lol

Image
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Irrlicht with MinGW Compiler

Post by CuteAlien »

Maybe you should figure out what's wrong with our machine first :-) Hard to diagnose, but you should at least check that you have current graphic card drivers. And when you get bluescreens it's usually also a good idea running memory checks (you can create boot cd's or usb-sticks with memtest on it - many Linux Live CD's also come with that).

You might have to rebuild Irrlicht. Run "make all_win32" in source/Irrlicht to do that.
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
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Irrlicht with MinGW Compiler

Post by mongoose7 »

What? The compiler couldn't create 'main.exe', probably because '../../bin/Win32-gcc' doesn't exist. And this probably because he is in the wrong directory. Because he won't do things properly!

'collect2.exe: error: ld returned 1 exit status' means everything worked correctly? And the compiler has *run* the program? I gasp!
alexescamilla
Posts: 8
Joined: Sat Apr 19, 2014 9:51 pm

Re: Irrlicht with MinGW Compiler

Post by alexescamilla »

i had it all in the correct place i dunno why it wouldnt work but i finally got vs 2013 to work for me
Post Reply