Page 1 of 1

fatal error: unresolved externals

Posted: Sun Dec 29, 2013 3:45 pm
by ingham19
I have completed Tutorials 1 and 2 now, but neither have actually run as I keep getting the error

"fatal error LNK1120: 1 unresolved externals"

The error information is: "error LNK2019: unresolved external symbol __imp__createDevice referenced in function _main"

Although I am new to Irrlicht, I have done plenty of C++ programming in Visual Studio 2010, and I assume there must be a quick fix for this error. Can anyone help?

Code: Select all

// Tutorial2.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <irrlicht.h>
#include <iostream>
 
using namespace irr;
 
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
 
 
int main()
{
    // ask user for driver
 
    video::E_DRIVER_TYPE driverType;
 
    printf("Please select the driver you want for this example:\n"\
        " (a) OpenGL 1.5\n (b) Direct3D 9.0c\n (c) Direct3D 8.1\n"\
        " (d) Burning's Software Renderer\n (e) Software Renderer\n"\
        " (f) NullDevice\n (otherKey) exit\n\n");
 
    char i;
    std::cin >> i;
 
    switch(i)
    {
        case 'a':driverType = video::EDT_OPENGL;    break;
        case 'b':driverType = video::EDT_DIRECT3D9; break;
        case 'c':driverType = video::EDT_DIRECT3D8; break;
        case 'd':driverType = video::EDT_BURNINGSVIDEO; break;
        case 'e':driverType = video::EDT_SOFTWARE;  break;
        case 'f':driverType = video::EDT_NULL;      break;
        default: return 1;
    }
 
    // create device and exit if creation failed
 
    IrrlichtDevice *device = 
        createDevice(driverType, core::dimension2d<u32>(640, 480));
 
    if (device == 0)
        return 1; // could not create selected driver.
 
    video::IVideoDriver* driver = device->getVideoDriver();
    scene::ISceneManager* smgr = device->getSceneManager();
 
    device->getFileSystem()->addFileArchive("../../media/map-20kdm2.pk3");
 
    scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
    scene::ISceneNode* node = 0;
 
    if (mesh)
        node = smgr->addOctreeSceneNode(mesh->getMesh(0), 0, -1, 1024);
//      node = smgr->addmeshSceneNode(mesh->getMesh(0));
 
    if (node)
        node->setPosition(core::vector3df(-1300,-144,-1249));
 
    smgr->addCameraSceneNodeFPS();
 
    device->getCursorControl()->setVisible(false);
 
    int lastFPS = -1;
 
    while(device->run())
    {
        if(device->isWindowActive())
        {
            driver->beginScene(true, true, video::SColor(255, 200, 200, 200));
            smgr->drawAll();
            driver->endScene();
 
            int fps = driver->getFPS();
 
            if (lastFPS != fps)
            {
                core::stringw str = L"Irrlicht Engine - Quake 3 Map example[";
 
                str += driver->getName();
                str += "] FPS:";
                str += fps;
 
                device->setWindowCaption(str.c_str());
                lastFPS = fps;
            }
        }
        else
            device->yield();
    }
 
    device->drop();
    return 0;
}

Re: fatal error: unresolved externals

Posted: Sun Dec 29, 2013 7:38 pm
by stefany
I thing you are not linking against the Irrlicht library. Add the library to the linker options.

Re: fatal error: unresolved externals

Posted: Sun Dec 29, 2013 7:50 pm
by ingham19
brkpnt wrote:I thing you are not linking against the Irrlicht library. Add the library to the linker options.
I have already linked the Irrlicht library. Perhaps I am doing it wrong. I right click on my project in the solution explorer > I go to VC++ Directories > I add the path to the include folder in the "include directory" and the path to the library in the "library directory". I have tried both the 64 bit and 32 bit versions, but I get the same error.

the path is C:\Apps\irrlicht-1.8\include for the include directory
and C:\Apps\irrlicht-1.8\lib\win64-visualStudio for the library directory

Any ideas???

Re: fatal error: unresolved externals

Posted: Mon Dec 30, 2013 6:30 am
by mongoose7
You added the path, now add the library. Look under "Linker" additional libraries. The library name must be given to the linker - it does not guess.

Re: fatal error: unresolved externals

Posted: Mon Dec 30, 2013 2:11 pm
by ingham19
mongoose7 wrote:You added the path, now add the library. Look under "Linker" additional libraries. The library name must be given to the linker - it does not guess.
I've gone to the "Linker" tab in properties. Where do I give the library name to the linker?

Re: fatal error: unresolved externals

Posted: Mon Dec 30, 2013 2:57 pm
by CuteAlien
For VS the pragma you are using above should already work when the correct library path is set. You need 64-bit if you compile with 64-bit and 32-bit if you compile with 32-bit. Adding the library to the linker in the propierties is possible but I'm on the wrong system right now so I can't tell you the name (something like libraries probably...).

Check if the path you have given in library directory does really contain a Irrlicht.lib

Re: fatal error: unresolved externals

Posted: Mon Dec 30, 2013 3:09 pm
by ingham19
CuteAlien wrote:For VS the pragma you are using above should already work when the correct library path is set. You need 64-bit if you compile with 64-bit and 32-bit if you compile with 32-bit. Adding the library to the linker in the propierties is possible but I'm on the wrong system right now so I can't tell you the name (something like libraries probably...).

Check if the path you have given in library directory does really contain a Irrlicht.lib
The Irrlicht.lib file is definitely in the library directory. I'm just not sure I'm linking it properly, I can't see an obvious place to do it.

Re: fatal error: unresolved externals

Posted: Mon Dec 30, 2013 5:27 pm
by Piter
Maybe you forgot to place the Irrlicht.dll?

Re: fatal error: unresolved externals

Posted: Mon Dec 30, 2013 9:35 pm
by CuteAlien
Missing dll would give runtime errors, unresolved external is a linker error.
But this line already does the linking in VS 2010 usually:

Code: Select all

 
#pragma comment(lib, "Irrlicht.lib")
 
When the correct library folder is set nothing else is needed. That's how the examples work... hm... do those work? (the project files in the examples directory I mean)