c++ - Directx8 error LNK2019: unresolved external symbol -


im making rpg game (diablo) graduation project. tried compiling jim adams programing rpg directx 8 sample.

ignore comments in other language.

/*-------------------------------------------------------------------------- ------------------===========================-------------------------------    iiiiiiii    iiiii     iiii      iii       iii   iiiii    ii      iiiii       iii  iii   iii     iii iii     iii     iii   iii iii   ii     iii iii      iii    ii  iii    iii   iii     iii   iii   iii  iii   ii    iii  iii      iii    ii  iii   iiiiiiiiiii     iii iii    iii  iii   ii    iii  iii     iiiiiiii    iiiii iii       iii     iiii       iiiiii    iiiiii iiiiii =================||||||||||||||||||||||||||||===============================  (c) braniselj klemen 2013                           ========================= ;;;;;;;;;;;;;;;;;;;/class za level 1 /;;;;;;;;;;;;;;;;;;;;;;                     ************************** */  #ifndef _act1_h_ #define _act1_h_  //dva tipa struktura ali quadtree(za levele z konstantno viŠino ali octree za levele z spremenljivo dolŽino enum treetypes { quadtree = 0, octree };  class cnodetreemesh { private:     //struktura pobere koordinate iz vertex bufferja modela     typedef struct svertex { float x, y, z; } svertex;      //textura je izrisana samo enkrat ne 60 na sekuno     typedef struct spolygon {         unsigned long group; //skupina teksture         unsigned long time;  //kdaj je bila nazadnje izrisana         unsigned short vertex[3]; //x, y ,z          spolygon() { group = time = 0; } //počisti podatke         } spolygon;      //struktura ohranja ševilo polygonov v 3d prostoru     typedef struct snode {         unsigned long numpolygons;         spolygon **polygonlist;         float xpos, ypos, zpos;         float size;         snode *nodes[8];          //konstruktor ki počisti spremenljivko         snode()         {              numpolygons = 0;             polygonlist = null;             xpos = ypos = zpos = size = 0.0f;             for(short i=0; i< 8; i++)                 nodes[i] = null;         }          ~snode()         {              delete [] polygonlist;              (short i=0; i<8; i++)                  delete nodes[i];         }     }snode;      //struktura ki grupira polygone ki morajo biti izrisani v vsakem framu     typedef struct sgroup {         cvertexbuffer vertexbuffer;         char *vertexptr;         unsigned long numpolygons;         unsigned long numpolygonstodraw;          sgroup() { numpolygons = 0; }         ~sgroup() { vertexbuffer.free(); }     } sgroup;      int m_treetype;   //quad ali octa      cgraphics *m_graphics;      cfrustum *m_frustum;      unsigned long m_time;      float m_size;     float m_maxsize;      snode *m_parentnode;      unsigned long m_numgroups;     sgroup *m_groups;      unsigned long  m_numpolygons;     unsigned long m_maxpolygons;     spolygon *m_polygonlist;      smesh *m_mesh;     char *m_vertexptr;     unsigned long m_vertexfvf;     unsigned long m_vertexsize;      void sortnode(snode *node, float xpos, float ypos, float zpos, float size);      void addnode(snode *node);      bool ispolygoncontained(spolygon *polygon, float xpos, float ypos, float zpos, float size);      unsigned long countpolygons( float xpos, float ypos, float zpos, float size);  public:     cnodetreemesh(); //konstruktor za model     ~cnodetreemesh(); //dekonstruktor za model       bool create(cgraphics *graphics, cmesh *mesh, int treetype = octree, float maxsize = 256.0f, long maxpolygons = 32);     bool free();      bool render(cfrustum *frustum = null, float  zdistance = 0.0f);      float getclosestheight(float xpos, float ypos, float zpos);      float getheightbelow(float xpos, float ypos, float zpos);     float getheightabove(float xpos, float ypos, float zpos);      bool checkintersect(float xstart, float ystart, float zstart, float xend, float yend, float zend, float *length);    };   #endif // _act1_h_ 

act1.cpp

/*------------------------------------------------------------------- ------------------===========================-------------------------------    iiiiiiii    iiiii     iiii      iii       iii   iiiii    ii      iiiii       iii  iii   iii     iii iii     iii     iii   iii iii   ii     iii iii      iii    ii  iii    iii   iii     iii   iii   iii  iii   ii    iii  iii      iii    ii  iii   iiiiiiiiiii     iii iii    iii  iii   ii    iii  iii     iiiiiiii    iiiii iii       iii     iiii       iiiiii    iiiiii iiiiii =================||||||||||||||||||||||||||||===============================  povzeto po jim adams programing role playing games directx (c) braniselj klemen 2013     node = del levela                           ========================= ;;;;;;;;;;;;;;;;;;;;;/funkcije za level 1/;;;;;;;;;;;;;;;;;;;;;;                     ************************** */  #include "core_global.h" #include "frustum.h" #include "act1.h"   #pragma comment(lib, "user32.lib")  #pragma comment(lib, "gdi32.lib") #pragma comment(lib,"d3d8.lib") #pragma comment(lib,"d3dx8.lib") #pragma comment(lib, "winmm.lib")   #include <windows.h> #include <iostream> #include <stdio.h> #include "d3d8.h" #include "d3dx8.h"  using namespace std;  cnodetreemesh::cnodetreemesh() {     m_treetype = octree;     m_graphics = null;     m_parentnode = null;     m_numpolygons = 0;     m_polygonlist = null;     m_numgroups = 0;     m_groups = null;     m_time = 0; }  cnodetreemesh::~cnodetreemesh() {     free(); }  bool cnodetreemesh::create(cgraphics *graphics, cmesh *mesh, int treetype, float maxsize, long maxpolygons) {     id3dxmesh *loadmesh;     unsigned short *indexptr;     dword *attributes;     unsigned long i;     float maxx, maxy, maxz;      free();       if((m_graphics = graphics ) == null)         return false;     if(mesh == null)         return false;     if(!mesh->getparentmesh()->m_nummaterials)         return false;      //lastnosti modela     m_mesh = mesh->getparentmesh();     loadmesh = m_mesh->m_mesh;     m_vertexfvf = loadmesh->getfvf();     m_vertexsize = d3dxgetfvfvertexsize(m_vertexfvf);     m_numpolygons = loadmesh->getnumfaces();     m_maxpolygons = maxpolygons;      //ustvarimo seznam poljgonov(drevo)     m_polygonlist = new spolygon[m_numpolygons]();     m_numgroups = m_mesh->m_nummaterials;     m_groups = new sgroup[m_numgroups]();      //zaklenemo vertex bufferje     loadmesh->lockindexbuffer(d3dlock_readonly, (byte**)&indexptr);     loadmesh->lockattributebuffer(d3dlock_readonly, &attributes);      //informacije polygona v strukturo     for(i = 0;  <m_numpolygons; i++)     {         m_polygonlist[i].vertex[0] = *indexptr++;         m_polygonlist[i].vertex[1] = *indexptr++;         m_polygonlist[i].vertex[2] = *indexptr++;          //shranimo texture group in stevec         m_polygonlist[i].group = attributes[i];         m_groups[attributes[i]].numpolygons++;     }      loadmesh->unlockindexbuffer();     loadmesh->unlockattributebuffer();      for(i = 0; < m_numgroups; i++)     {         if(m_groups[i].numpolygons != 0)             m_groups[i].vertexbuffer.create(m_graphics, m_groups[i].numpolygons * 3, m_vertexfvf, m_vertexsize);     }      //velikost kocke     maxx = (float)max(fabs(mesh->getparentmesh()->m_min.x), fabs(mesh->getparentmesh()->m_max.x));     maxy = (float)max(fabs(mesh->getparentmesh()->m_min.y), fabs(mesh->getparentmesh()->m_max.y));     maxz = (float)max(fabs(mesh->getparentmesh()->m_min.z), fabs(mesh->getparentmesh()->m_max.z));     m_size = max(maxx, max(maxy, maxz)) * 2.0f;     m_maxsize = maxsize;      //ustvarimo starševsko vozlišče     m_parentnode = new snode();      loadmesh->lockvertexbuffer(d3dlock_readonly, (byte**)&m_vertexptr);     sortnode(m_parentnode, 0.0f, 0.0f, 0.0f, m_size);     loadmesh->unlockvertexbuffer();      return true; }   //"sprostimo" model bool cnodetreemesh::free() {     delete m_parentnode;     m_parentnode = null;      m_graphics = null;     m_numpolygons = 0;     delete [] m_polygonlist;     m_polygonlist = null;      m_numgroups = 0;     delete [] m_groups;     m_groups = null;      return true; }  void cnodetreemesh::sortnode(snode *node, float xpos, float ypos, float zpos, float size) {     unsigned long i, num;     float xoff, yoff, zoff;     //kakšna napaka     if(node == null || m_polygonlist == null)         return;      //koordinate node-ov     node->xpos = xpos;     node->ypos = (m_treetype == quadtree)?0.0f:ypos;     node->zpos = zpos;     node->size = size;      //ali plyigoni v nodu     if(!(num = countpolygons(xpos, ypos, zpos, size)))         return;      //Če je preveč polygoonov v nodu razdeli     if(size > m_maxsize && num > m_maxpolygons)     {         for(i=0; i<(unsigned long)((m_treetype == quadtree)?4:8);i++)         {             xoff = ((( % 2 ) < 1) ? -1.0f : 1.0f ) * (size * 4.0f);             yoff = ((( % 4 ) < 1) ? -1.0f : 1.0f ) * (size * 4.0f);             zoff = ((( % 8 ) < 1) ? -1.0f : 1.0f ) * (size * 4.0f);              //ali polygoni v zajemu noda             if(countpolygons(xpos+xoff, ypos+yoff, zpos+zoff, size/2.0f))             {                 node->nodes[i] = new snode();                  sortnode(node->nodes[i], xpos+xoff, ypos+yoff, zpos+zoff, size/2.0f);             }         }         return;     }      //allokacija prostora za kazalce na polygon     node->numpolygons = num;     node->polygonlist = new spolygon*[num];      //shranjuje kazalce     num = 0;     ( i=0; i<m_numpolygons; i++)     {         //dodaj polygon če je zajet v 3d prostoru         if(ispolygoncontained(&m_polygonlist[i], xpos, ypos, zpos, size) == true)      node->polygonlist[num++] = &m_polygonlist[i];     } }  bool cnodetreemesh::ispolygoncontained(spolygon *polygon, float xpos, float ypos, float zpos, float size) {     float xmin, xmax, ymin, ymax, zmin, zmax;     svertex *vertex[3];      //vertices(točke) polygona     vertex[0] =(svertex*)&m_vertexptr[m_vertexsize * polygon->vertex[0]];     vertex[1] =(svertex*)&m_vertexptr[m_vertexsize * polygon->vertex[1]];     vertex[2] =(svertex*)&m_vertexptr[m_vertexsize * polygon->vertex[2]];      // preveri po x osi   xmin = min(vertex[0]->x, min(vertex[1]->x, vertex[2]->x));   xmax = max(vertex[0]->x, max(vertex[1]->x, vertex[2]->x));   if(xmax < (xpos - size / 2.0f))   return false;   if(xmin > (xpos + size / 2.0f))   return false;    // preveri po y osi   if(m_treetype == octree) {     ymin = min(vertex[0]->y, min(vertex[1]->y, vertex[2]->y));     ymax = max(vertex[0]->y, max(vertex[1]->y, vertex[2]->y));     if(ymax < (ypos - size / 2.0f))     return false;     if(ymin > (ypos + size / 2.0f))     return false;   }    // preveri po z osi   zmin = min(vertex[0]->z, min(vertex[1]->z, vertex[2]->z));   zmax = max(vertex[0]->z, max(vertex[1]->z, vertex[2]->z));   if(zmax < (zpos - size / 2.0f))   return false;   if(zmin > (zpos + size / 2.0f))   return false;    return true; }  unsigned long cnodetreemesh::countpolygons(float xpos, float ypos, float zpos, float size) {     unsigned long i, num;     // ali je kakšen polygon za procesirati   if(!m_numpolygons)     return 0;    // preglej kateri polygoni zajeti v 3d prostoru   num = 0;   for( i=0; i<m_numpolygons; i++ ) {     if(ispolygoncontained(&m_polygonlist[i],xpos,ypos,zpos,size) == true)      num++;   }    return num; }  bool cnodetreemesh::render(cfrustum *frustum, float zdistance) {   d3dxmatrix matrix;     cfrustum viewfrustum;      // ali je kje kakšna napaka   if(m_graphics == null || m_parentnode == null || !m_numpolygons)     return false;    // ustvari pogled   if((m_frustum = frustum) == null) {     viewfrustum.construct(m_graphics, zdistance);     m_frustum = &viewfrustum;   }    d3dxmatrixidentity(&matrix);   m_graphics->getdevicecom()->settransform(d3dts_world, &matrix);    // zakleni vertex buffer   for(unsigned long i=0; i<m_numgroups; i++) {     m_groups[i].vertexbuffer.lock(0,0);     m_groups[i].vertexptr = (char*)m_groups[i].vertexbuffer.getptr();     m_groups[i].numpolygonstodraw = 0;   }   m_mesh->m_mesh->lockvertexbuffer(d3dlock_readonly, (byte**)&m_vertexptr);    // shrani trenutni čas  v render   m_time = timegettime();    // dodaj polygone v vertex buffer   addnode(m_parentnode);    // odkleni vertex bufferje in izriši   m_mesh->m_mesh->unlockvertexbuffer();   for(unsigned long i=0; i<m_numgroups; i++) {     m_groups[i].vertexbuffer.unlock();      if(m_groups[i].numpolygonstodraw) {       m_graphics->getdevicecom()->setmaterial(&m_mesh->m_materials[i]);       m_graphics->getdevicecom()->settexture(0, m_mesh->m_textures[i]);        m_groups[i].vertexbuffer.render(0, m_groups[i].numpolygonstodraw, d3dpt_trianglelist);     }   }    return true; }  void cnodetreemesh::addnode(snode *node) {   unsigned long i, group;   short         num;    // preveri pogled glede    if(m_treetype == quadtree) {     if(m_frustum->checkrectangle(            node->xpos,        0.0f,          node->zpos,             node->size / 2.0f, m_size / 2.0f, node->size / 2.0f) == false)       return;   } else {     if(m_frustum->checkrectangle(            node->xpos,        node->ypos,        node->zpos,             node->size / 2.0f, node->size / 2.0f, node->size / 2.0f) == false)       return;   }     num = 0;   for(i=0;i<(unsigned long)((m_treetype==quadtree)?4:8);i++) {     if(node->nodes[i] != null) {       num++;       addnode(node->nodes[i]);     }   }     if(num)     return;     if(node->numpolygons != 0) {     for(i=0;i<node->numpolygons;i++) {        // če polygon še ni buil izrisan       if(node->polygonlist[i]->time != m_time && (group = node->polygonlist[i]->group) < m_numgroups) {          // izriši polygone ki vidni          if(m_mesh->m_materials[node->polygonlist[i]->group].diffuse.a != 0.0f) {             memcpy(m_groups[group].vertexptr, &m_vertexptr[m_vertexsize * node->polygonlist[i]->vertex[0]], m_vertexsize);           m_groups[group].vertexptr += m_vertexsize;           memcpy(m_groups[group].vertexptr, &m_vertexptr[m_vertexsize * node->polygonlist[i]->vertex[1]], m_vertexsize);           m_groups[group].vertexptr += m_vertexsize;           memcpy(m_groups[group].vertexptr, &m_vertexptr[m_vertexsize * node->polygonlist[i]->vertex[2]], m_vertexsize);           m_groups[group].vertexptr += m_vertexsize;            m_groups[group].numpolygonstodraw++;         }          // označi polygon ki je bil sprocesiran v določenem časovnem segmentu         node->polygonlist[i]->time = m_time;       }     }   } }  float cnodetreemesh::getclosestheight(float xpos, float ypos, float zpos) {   float yabove, ybelow;    yabove = getheightabove(xpos, ypos, zpos);   ybelow = getheightbelow(xpos, ypos, zpos);   if(fabs(yabove-ypos) < fabs(ybelow-ypos))     return yabove;   return ybelow; }  float cnodetreemesh::getheightbelow(float xpos, float ypos, float zpos) {   bool  hit;   float u, v, dist;   dword faceindex;    d3dxintersect(m_mesh->m_mesh, &d3dxvector3(xpos,ypos,zpos), &d3dxvector3(0.0f, -1.0f, 0.0f),&hit, &faceindex, &u, &v, &dist, null, null);   if(hit == true)     return ypos-dist;   return ypos; }  float cnodetreemesh::getheightabove(float xpos, float ypos, float zpos) {    bool  hit;   float u, v, dist;   dword faceindex;    d3dxintersect(m_mesh->m_mesh,                 &d3dxvector3(xpos,ypos,zpos),                 &d3dxvector3(0.0f, 1.0f, 0.0f),                 &hit, &faceindex, &u, &v, &dist , null, null);   if(hit == true)     return ypos+dist;   return ypos; }  bool cnodetreemesh::checkintersect(float xstart, float ystart, float zstart,                                    float xend,   float yend,   float zend,                                    float *length) {   bool  hit;   float u, v, dist;   float xdiff, ydiff, zdiff, size;   dword faceindex;   d3dxvector3 vecdir;    xdiff = xend - xstart;   ydiff = yend - ystart;   zdiff = zend - zstart;    d3dxvec3normalize(&vecdir, &d3dxvector3(xdiff, ydiff, zdiff));   d3dxintersect(m_mesh->m_mesh, &d3dxvector3(xstart,ystart,zstart), &vecdir,&hit, &faceindex, &u, &v, &dist, null, null);    if(hit == true) {     size = (float)sqrt(xdiff*xdiff+ydiff*ydiff+zdiff*zdiff);     if(dist > size)       hit = false;     else {       if(length != null)         *length = dist;     }   }    return hit; } 

yes linked lib files in aditional dependencies

d3d8.lib; d3dx8d.lib; d3dx8.lib; winmm.lib; odbc32.lib; odbccp32.lib; libcmtd.lib; user32.lib; gdi32.lib; kernel32.lib; winspool.lib; comdlg32.lib; advapi32.lib; shell32.lib; ole32.lib; oleaut32.lib; uuid.lib; wsock32.lib; d3dxof.lib; dxguid.lib; d3dx.lib; dsound.lib; dinput8.lib; dplayx.lib; %(additionaldependencies) 

i thease erros:

1>build started 1.3.2013 17:45:31. 1>initializebuildstatus: 1>  touching "debug\diavolo.unsuccessfulbuild". 1>clcompile: 1>  act1.cpp 1>  c:\program files (x86)\microsoft sdks\windows\v7.0a\include\dinput.h: directinput_version undefined. defaulting version 0x0800 1>manifestresourcecompile: 1>  outputs up-to-date. 1>libcmtd.lib(crt0.obj) : error lnk2001: unresolved external symbol _main 1>act1.obj : error lnk2019: unresolved external symbol "public: int __thiscall cvertexbuffer::create(class cgraphics *,unsigned long,unsigned long,long)" (?create@cvertexbuffer@@qaehpavcgraphics@@kkj@z) referenced in function "public: int __thiscall cnodetreemesh::create(class cgraphics *,class cmesh *,int,float,long)" (?create@cnodetreemesh@@qaehpavcgraphics@@pavcmesh@@hmj@z) 1>act1.obj : error lnk2019: unresolved external symbol "public: struct smesh * __thiscall cmesh::getparentmesh(void)" (?getparentmesh@cmesh@@qaepausmesh@@xz) referenced in function "public: int __thiscall cnodetreemesh::create(class cgraphics *,class cmesh *,int,float,long)" (?create@cnodetreemesh@@qaehpavcgraphics@@pavcmesh@@hmj@z) 1>act1.obj : error lnk2019: unresolved external symbol "public: __thiscall cvertexbuffer::cvertexbuffer(void)" (??0cvertexbuffer@@qae@xz) referenced in function "public: __thiscall cnodetreemesh::sgroup::sgroup(void)" (??0sgroup@cnodetreemesh@@qae@xz) 1>act1.obj : error lnk2019: unresolved external symbol "public: __thiscall cvertexbuffer::~cvertexbuffer(void)" (??1cvertexbuffer@@qae@xz) referenced in function "public: __thiscall cnodetreemesh::sgroup::~sgroup(void)" (??1sgroup@cnodetreemesh@@qae@xz) 1>act1.obj : error lnk2019: unresolved external symbol "public: int __thiscall cvertexbuffer::free(void)" (?free@cvertexbuffer@@qaehxz) referenced in function "public: __thiscall cnodetreemesh::sgroup::~sgroup(void)" (??1sgroup@cnodetreemesh@@qae@xz) 1>act1.obj : error lnk2019: unresolved external symbol "public: int __thiscall cvertexbuffer::render(unsigned long,unsigned long,unsigned long)" (?render@cvertexbuffer@@qaehkkk@z) referenced in function "public: int __thiscall cnodetreemesh::render(class cfrustum *,float)" (?render@cnodetreemesh@@qaehpavcfrustum@@m@z) 1>act1.obj : error lnk2019: unresolved external symbol "public: int __thiscall cvertexbuffer::unlock(void)" (?unlock@cvertexbuffer@@qaehxz) referenced in function "public: int __thiscall cnodetreemesh::render(class cfrustum *,float)" (?render@cnodetreemesh@@qaehpavcfrustum@@m@z) 1>act1.obj : error lnk2019: unresolved external symbol "public: void * __thiscall cvertexbuffer::getptr(void)" (?getptr@cvertexbuffer@@qaepaxxz) referenced in function "public: int __thiscall cnodetreemesh::render(class cfrustum *,float)" (?render@cnodetreemesh@@qaehpavcfrustum@@m@z) 1>act1.obj : error lnk2019: unresolved external symbol "public: int __thiscall cvertexbuffer::lock(unsigned long,unsigned long)" (?lock@cvertexbuffer@@qaehkk@z) referenced in function "public: int __thiscall cnodetreemesh::render(class cfrustum *,float)" (?render@cnodetreemesh@@qaehpavcfrustum@@m@z) 1>act1.obj : error lnk2019: unresolved external symbol "public: struct idirect3ddevice8 * __thiscall cgraphics::getdevicecom(void)" (?getdevicecom@cgraphics@@qaepauidirect3ddevice8@@xz) referenced in function "public: int __thiscall cnodetreemesh::render(class cfrustum *,float)" (?render@cnodetreemesh@@qaehpavcfrustum@@m@z) 1>frustum.obj : error lnk2001: unresolved external symbol "public: struct idirect3ddevice8 * __thiscall cgraphics::getdevicecom(void)" (?getdevicecom@cgraphics@@qaepauidirect3ddevice8@@xz) 1>.\debug\diavolo.exe : fatal error lnk1120: 11 unresolved externals 1> 1>build failed. 1> 1>time elapsed 00:00:01.57 ========== build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

sorry bad english. appriciated

you getting linker errors because don't link d3dx9.lib, d3dx9d.lib , d3d9.lib.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -