2

我正在尝试使用 VS 2010 构建Irrlicht 的示例 01.HelloWorld"。当我这样做时出现错误:

LNK2019:函数 _main 中引用的未解析的外部符号 __imp__createDevice

我找到了解决此问题的可能解决方案,并尝试在答案中应用一些解决方案,方法是更改 int main​​为int _tmain(int argc, _TCHAR* argv[])andint _tmain()但它没有用。

#include <irrlicht.h>

using namespace irr;

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

#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
#include <tchar.h>

int main()
{
    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");

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

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

    IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
    if (!mesh)
    {
        device->drop();
        return 1;
    }
    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;
}
4

2 回答 2

1

根据您提供的内容,有三种可能的解决方案:

  1. 您没有将 lib/VisualStudio 添加到其他链接器目录中。

  2. 项目目录中缺少 IrrLicht.dll。

  3. 代码正在寻找_main()、 notmain()和 not _tmain()。尝试更改int main()int _main().

这可能行不通,但这是我能做的最好的事情。

于 2014-01-15T19:24:00.940 回答
0

What fixed this for me was adding

#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
于 2014-08-02T19:02:57.403 回答