2014-01-15 64 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

相關問題