2014-01-15 59 views
2

我尝试使用VS 2010构建示例01.HelloWorld" of Irrlicht当我做我的错误:Irrlicht的LNK2019:解析外部符号__imp__createDevice在函数引用_main

LNK2019: unresolved external symbol __imp__createDevice referenced in function _main

,我发现这个问题的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; 
} 
+0

您可以发布运行'DUMPBIN /符号Irrlicht.lib的结果| grep createDevice'到问题中? –

回答

1

刚上您所提供的东西,有三种可能的解决方案:

  1. 你没有的lib/VisualStudio中添加到您的附加链接器的目录。

  2. IrrLicht.dll从项目目录中丢失。

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

这可能不会工作,但它是我能做的最好的工作。

+0

谢谢!我寻找这个解决方案,并且将路径添加到C:\ bin \ irrlicht-1.8.1 \ lib \ Win32-visualstudio为我做了诀窍 – hansmei

0

什么固定的这对我来说是增加

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

这是否已经在op的代码中? – ChiefTwoPencils

相关问题