【问题标题】:Irrlicht LNK2019: unresolved external symbol __imp__createDevice referenced in function _mainIrrlicht LNK2019:函数 _main 中引用的未解析的外部符号 __imp__createDevice
【发布时间】:2014-01-15 18:02:47
【问题描述】:

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

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

我为这个问题找到了possible solution,并尝试在答案中应用一些解决方案,将int main 更改为int _tmain(int argc, _TCHAR* argv[])int _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;
}

【问题讨论】:

  • 能否将运行dumpbin /symbols Irrlicht.lib | grep createDevice的结果发布到问题中?

标签: c++ visual-studio-2010 irrlicht


【解决方案1】:

就您提供的内容而言,有三种可能的解决方案:

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

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

  3. 代码正在寻找_main(),而不是main(),而不是_tmain()。尝试将int main() 更改为int _main()

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

【讨论】:

  • 谢谢!我寻找了这个解决方案,并将路径添加到 C:\bin\irrlicht-1.8.1\lib\Win32-visualstudio 为我解决了问题
【解决方案2】:

为我解决这个问题的是添加

#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif

【讨论】:

    猜你喜欢
    • 2013-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-18
    相关资源
    最近更新 更多