2

I'm currently working with MinGW compiling C++ programs. I downloaded irrlicht-1.8 and am trying to do the first tutorial. It is finding the header file, but when I try to compile I get the following error:

C:\Users\E5DC9~1.MAR\AppData\Local\Temp\ccfR3pSv.o:LightSpacePrototype.C<.text+0xb12>: undefined reference to '__imp__createDevice'

collect2: ld returned 1exit status

I should note that this a public computer on which I have a private account on their network. I have no administrator privileges. This is the only windows computer I have access to. Where do I begin? I have no idea what that error means. My .c file isn't even in the C drive. It's on the H drive. When compiling, I give the following command in a .bat file:

H:

CD H:\Desktop\MinGW\Bin

G++ H:\Desktop\MinGW\SOURCE\LightSpacePrototype.C -o H:\Desktop\MinGW\COMPILED\LightSpacePrototype.exe -L H:\Desktop\MinGW\irrlicht-1.8\lib\Win32-gcc -I H:\Desktop\MinGW\irrlicht-1.8\include

CMD

the -I to specify the header file directory to search, as I said above, works fine. I am confused by the library directory though, as the tutorial is for Visual C++, not MinGW. So the tutorial said to specify the path as H:\Desktop\MinGW\irrlicht-1.8\lib\Win32-visualstudio rather than H:\Desktop\MinGW\irrlicht-1.8\lib\Win32-gcc like I have it. I assume I'm supposed to use gcc, as that seeems to be the MinGW version. However, in the tutorial it said I needed "#pragma comment(lib, "Irrlicht.lib")" But in the Win32-gcc there is no Irrlicht.lib file, just two other files called libIrrlicht.a and libIrrlicht.def, however there is a Irrlicht.lib file in the Win32-visualstudio folder. I have tried removing the pragma comment and switching the library directory, but neither that nor any combination of that works. My friend tells me that the error means that the compiler cannot find a file it needs, but I have no idea what file that is. I only assume that it is Irrlicht.lib.

Source code:

#include "irrlicht.h"

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#pragma comment(lib, "Irrlicht.lib")

int main()
{

IrrlichtDevice *device = createDevice(EDT_SOFTWARE, dimension2d<u32>(512, 384), 16, false, false, false, 0);

device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");

IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
IGUIEnvironment *guienv = device->getGUIEnvironment();

guienv->addStaticText(L"Hello World! This is the Irrlicht Software engine!", rect<s32>(10,10,200,22), true);

IAnimatedMesh *mesh = smgr->getMesh("H:Desktop\MinGW\irrlicht-1.8\media\sydney.md2");
IAnimatedMeshSceneNode *node = smgr->addAnimatedMeshSceneNode(mesh);

if(node)
{

    node->setMaterialFlag(EMF_LIGHTING, false);
    node->setFrameLoop(0, 310);     
    node->setMaterialTexture(0, driver->getTexture("H:Desktop\MinGW\irrlicht-1.8\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;
}
Community
  • 1
  • 1
user1914745
  • 73
  • 1
  • 7

1 Answers1

0

Solution from OP.

Let me first say that while what I did allows it to compile, it does not execute due to some 32 bit/64 bit error, but that's another topic.

There were two problems:

-Compiler was not compiling a library

-Compiler was not including a library

For the first problem, I had to add -c to the start of the compiling command, t tell it to compile the library files. For the second, I had to use -l and specify the library file to include.

H:

CD H:\Desktop\MinGW\Bin

G++ -c H:\Desktop\MinGW\SOURCE\LightSpacePrototype.C -o H:\Desktop\MinGW\COMPILED\LightSpacePrototype.exe -L H:\Desktop\MinGW\irrlicht-1.8\lib\Win32-gcc -l H:\Desktop\MinGW\irrlicht-1.8\lib\Win32-gcc\libIrrlicht.a -I H:\Desktop\MinGW\irrlicht-1.8\include

CMD

For the pragma comment, I just did this:

#pragma comment(lib, "libIrrlicht.a")
Community
  • 1
  • 1
Cœur
  • 37,241
  • 25
  • 195
  • 267