8 Replies - 7027 Views - Last Post: 04 April 2012 - 12:02 AM Rate Topic: -----

#1 saggio  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 02-April 12

Linking error LNK2019: unresolved external symbol

Posted 02 April 2012 - 07:33 AM

Hello,

I'm trying to compile a .dll for use in another program, but get a whole bunch of linking errors. Have been trying to make it compile for almost a week now and I'm getting really desperate. The code is actually a demo case for a program and should therefore work.

I've tried both Visual C++ 2005 Express Edition and Visual Studio 2008. I've installed SDKs, .NETs and MSDN Library. Also re-installed both the addons and Visual 2005 and 2008 a couple of times without success.

I'm quite new to C++ programming, only some weeks of experience, so possibly the error is not difficult to fix. However, I've tried every concievable tip from other threads, but nothing seems to work. I made a small console program and compiled as a .exe and that worked fine. Guess DLLs are more tricky.

Please help!!

I attach the cpp code below, as well as the linking errors. I dont attach the header files, but as far as I know they are properly added to the solution.



#include "udmlbridge.h"
#include <math.h>
#include "cmodel.h"
#include "udm_types.h"
#include "umdvect3.h"

static CM_lbridge cm_lbridge(true);

CM_lbridge::CM_lbridge( bool bRegister, ICodeFunc *cf ) :
  ContactModel(ulCM_lbridge, bRegister),
    kn_load(0.0), kn_unload(0.0), kn_m(0.0), ks(0.0), fric(0.0),
    bmode(0),lb_nstr(0.0),lb_sstr(0.0),
    bObj2IsBall(true), sp_damp(0.8), bNtension(false),
    bInheritProp(false),
    u_old(0.0), u_zero(0.0), u_zeroo(0.0), u_max(0.0), n_force_old(0.0) {
  SetDelete( true );
  MustOverlap( false );
  if (cf) SetProp(*cf);
}

const char *CM_lbridge::Name(void) const {
  return("udm_lbridge");
}

const char **CM_lbridge::PropNames(void) const {
  static const char *strKey[] = {
    "lb_knm" , "lb_dampn", "lb_ks"       , "lb_fric",
    "lb_nstr", "lb_sstr" , "lb_notension", "lb_inheritprop", 
    0
  };
  return(strKey);
}

double CM_lbridge::ReturnProp(int n) const {
  switch (n) {
    case 0 : return kn_m;
    case 1 : return sp_damp;
    case 2 : return ks;
    case 3 : return fric;
    case 4 : return lb_nstr;
    case 5 : return lb_sstr;
    case 6 : return bNtension ? 1.0 : 0.0;
    case 7 : return bInheritProp ? 1.0 : 0.0;
    default: return 0.0;
  }
}

void CM_lbridge::AcceptProp(int n, double v) {
  switch (n) {
    case 0:  kn_m      = v;                        break;
    case 1:  sp_damp   = v;                        break;
    case 2:  ks        = v;                        break;
    case 3:  fric      = v;                        break;
    case 4:  lb_nstr  = v;                        break;
    case 5:  lb_sstr  = v;                        break;
    case 6:  bNtension = v!=0.0 ? true : false;    break;
    case 7:  bInheritProp = v!=0.0 ? true : false; break;
  }
  SetKn();
}

const char *CM_lbridge::PreCycle(ICodeFunc &cf) {
  if(bInheritProp) 
    SetProp(cf);
  else if (!bmode && (lb_nstr || lb_sstr))
    bmode = 3;
  if(!bNtension && (sp_damp>1.0 || sp_damp<0.4))
    return("range of damping factor : 0.4 <= damp_lbridge <= 1");
  if( bNtension && (sp_damp>1.0 || sp_damp<0.05))
    return("range of damping factor : 0.05 <= damp_lbridge <= 1");
  return(0);
}

void CM_lbridge::SetProp(ICodeFunc &cf) {
  ICodeFunc::cProp cp = cf.c_prop();
  kn_m        = cp.kn;
  ks          = cp.ks;
  fric        = cp.fric;
  lb_nstr    = cp.nstr;
  lb_sstr    = cp.sstr;
  if (bInheritProp && cp.bflag){
    bmode = 3;
  }
  bObj2IsBall = cf.c_state().Obj2IsBall;
  SetKn();
}

void CM_lbridge::SetKn(void) {
  kn_load   = 2.0*sp_damp*kn_m/(1.0+sp_damp);
  kn_unload = 2.0*kn_m/(1.0+sp_damp);
}

void CM_lbridge::FDLaw( FdBlock& fb, ICodeFunc &cf ) {
  if (fb.u_n<=0.0 && bmode<3) { // unbonded
    fb.n_force = 0.0;
    if ( cf.dim() == 2 )
      fb.s_force  = 0.0;
    else
      fb_s_force.Fill(0.0);
    u_old = 0.0;
    u_zero = 0.0;
    u_zeroo = 0.0;
    u_max = 0.0;
    n_force_old = 0.0;
    fb.knest = 0.0;
    fb.ksest = 0.0;
    fb.active = false;
  }
  else {  // fb.u_n > 0 or bonded
    if(!bNtension) {   // with tensile force
      if (fb.u_n - u_old >= 0.0 && n_force_old >= 0.0
          || fb.u_n - u_old <= 0.0 && n_force_old <= 0.0) {  // loading
        fb.n_force = kn_load*(fb.u_n - u_zero);
        u_max = fb.u_n;
        u_zeroo = u_zero;
      }
      else {                                                // unloading
        fb.n_force = kn_unload*(fb.u_n - u_max) - kn_load*(u_zeroo - u_max);
        if (kn_load!=0.0) u_zero =  fb.u_n - fb.n_force/kn_load;
        else              u_zero =  fb.u_n;
        if (fb.n_force * n_force_old < 0.0) {     // transition into loading
          u_zero = (kn_unload*u_max + kn_load*(u_zeroo-u_max)) / kn_unload;
          fb.n_force = kn_load*(fb.u_n - u_zero);
          u_max = fb.u_n;
          u_zeroo = u_zero;
        }
      }
      n_force_old = fb.n_force;
    }
    else {   // without tensile force
      if (fb.u_n - u_old >= 0.0) {
        fb.n_force = kn_load*(fb.u_n - u_zero);
        u_max = fb.u_n;
        u_zeroo = u_zero;
      }
      else {
        fb.n_force = kn_unload*(fb.u_n - u_max) - kn_load*(u_zeroo - u_max);
        if (fb.n_force < 0.0) fb.n_force = 0.0;
        if (kn_load!=0.0) u_zero =  fb.u_n - fb.n_force/kn_load;
        else              u_zero =  fb.u_n;
      }
    }
    u_old = fb.u_n;
    if ( cf.dim() == 2 )
      fb.s_force  -= fb.u_dot_s*ks*fb.tdel;
    else
      fb_s_force  -= fb_u_dot_s*ks*fb.tdel;

    if (bmode == 3)  // bonding check
      CheckBonding(fb,cf);
    else {           // sliding check
      double max_s_force = fabs(fb.n_force * fric);
      if ( cf.dim() == 2 ) {
        double sfmag = fabs(fb.s_force);
        if(sfmag > max_s_force) {
          fb.s_force = fb.s_force * max_s_force / sfmag;
          fb.bsliding = true;
        }
      }
      else {
        double dX = fb.pts_force->x;
        double dY = fb.pts_force->y;
        double dZ = fb.pts_force->z;
        double sfmag = sqrt(dX*dX + dY*dY + dZ*dZ);
        if(sfmag > max_s_force) {
          fb_s_force = fb_s_force * max_s_force / sfmag;
          fb.bsliding = true;
        }
      }
    }
    fb.knest = kn_unload;
    fb.ksest = ks;
  }
}

void CM_lbridge::CheckBonding(FdBlock &fb,  ICodeFunc &cf) {
  if (bObj2IsBall) {
    if (cf.dim()==2) {  // PFC2D
      if (-fb.n_force >= lb_nstr) {
        bmode = 1;
        cf.fc_udm( 0 );  // break in tension
        fb.n_force = 0.0;
        fb.s_force  = 0.0;
      }
      else if (fabs(fb.s_force) >= lb_sstr) {
        bmode = 2;
        cf.fc_udm( 1 ); // break in shear     
      }
    }
    else {  // PFC3D
      if (-fb.n_force >= lb_nstr) {
        bmode = 1;
        cf.fc_udm( 0 );  // break in tension
        fb.n_force = 0.0;
        fb_s_force.Fill(0.0);
      }
      else {
        double dX = fb.pts_force->x;
        double dY = fb.pts_force->y;
        double dZ = fb.pts_force->z;
        double dMag = sqrt(dX*dX + dY*dY + dZ*dZ);
        if (dMag >= lb_sstr) {
          bmode = 2;
          cf.fc_udm( 1 );  // break in shear    
        }
      }
    }
  }
  fb.bflag = (bmode == 3) ? true : false;
}

const char *CM_lbridge::SaveRestore(ModelSaveObject *mso) {
  const char *str = ContactModel::SaveRestore(mso);
  if (str) return str;
  if (mso->ulVersion < Version()) {
    mso->Initialize(11,0,4);
    mso->Save( 0, delete_flag);   //bools...
    mso->Save( 1, must_overlap);
    mso->Save( 2, bNtension);
    mso->Save( 3, bInheritProp);
    mso->Save( 0, kn_load);       //doubles...
    mso->Save( 1, kn_unload);
    mso->Save( 2, kn_m);
    mso->Save( 3, ks);
    mso->Save( 4, fric);
    mso->Save( 5, sp_damp);
    mso->Save( 6, u_old);
    mso->Save( 7, u_zero);
    mso->Save( 8, u_zeroo);
    mso->Save( 9, u_max);
    mso->Save(10, n_force_old);
  }
  else {
    mso->Initialize(13,1,4);
    mso->Save( 0, delete_flag);   //bools...
    mso->Save( 1, must_overlap);
    mso->Save( 2, bNtension);
    mso->Save( 3, bInheritProp);
    mso->Save( 0, kn_load);       //doubles...
    mso->Save( 1, kn_unload);
    mso->Save( 2, kn_m);
    mso->Save( 3, ks);
    mso->Save( 4, fric);
    mso->Save( 5, sp_damp);
    mso->Save( 6, u_old);
    mso->Save( 7, u_zero);
    mso->Save( 8, u_zeroo);
    mso->Save( 9, u_max);
    mso->Save(10, n_force_old);
    mso->Save(11, lb_nstr);
    mso->Save(12, lb_sstr);
    mso->Save(0, bmode);      // ints...
  }
  return 0;
}
/* EOF */



1>------ Build started: Project: udm_bridge, Configuration: Debug Win32 ------
1>Compiling...
1>udm_bridge.cpp
1>Linking...
1> Creating library C:\Simulation\Itasca\CPP Code\udm_bridge\Debug\udm_bridge.lib and object C:\Simulation\Itasca\CPP Code\udm_bridge\Debug\udm_bridge.exp
1>udm_bridge.obj : error LNK2028: unresolved token (0A00005F) "public: virtual char const * __thiscall ContactModel::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@ContactModel@@$$FUAEPBDPAUModelSaveObject@@@Z) referenced in function "public: virtual char const * __thiscall CM_lbridge::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@CM_lbridge@@$$FUAEPBDPAUModelSaveObject@@@Z)
1>udm_bridge.obj : error LNK2028: unresolved token (0A000060) "public: __thiscall ContactModel::ContactModel(unsigned long,bool)" (??0ContactModel@@$$FQAE@K_N@Z) referenced in function "public: __thiscall CM_lbridge::CM_lbridge(bool,class ICodeFunc *)" (??0CM_lbridge@@$$FQAE@_NPAVICodeFunc@@@Z)
1>udm_bridge.obj : error LNK2028: unresolved token (0A000061) "public: virtual __thiscall ContactModel::~ContactModel(void)" (??1ContactModel@@$$FUAE@XZ) referenced in function "public: virtual __thiscall CM_lbridge::~CM_lbridge(void)" (??1CM_lbridge@@$$FUAE@XZ)
1>udm_bridge.obj : error LNK2028: unresolved token (0A000067) "public: void __thiscall UMdvect3::Fill(double)" (?Fill@UMdvect3@@$$FQAEXN@Z) referenced in function "public: void __thiscall CM_lbridge::CheckBonding(struct FdBlock &,class ICodeFunc &)" (?CheckBonding@CM_lbridge@@$$FQAEXAAUFdBlock@@AAVICodeFunc@@@Z)
1>udm_bridge.obj : error LNK2028: unresolved token (0A000068) "public: void __thiscall UMdvect3::operator-=(class UMdvect3 const &)" (??ZUMdvect3@@$$FQAEXABV0@@Z) referenced in function "public: virtual void __thiscall CM_lbridge::FDLaw(struct FdBlock &,class ICodeFunc &)" (?FDLaw@CM_lbridge@@$$FUAEXAAUFdBlock@@AAVICodeFunc@@@Z)
1>udm_bridge.obj : error LNK2028: unresolved token (0A000069) "public: class UMdvect3 __thiscall UMdvect3::operator*(double const &)const " (??DUMdvect3@@$$FQBE?AV0@ABN@Z) referenced in function "public: virtual void __thiscall CM_lbridge::FDLaw(struct FdBlock &,class ICodeFunc &)" (?FDLaw@CM_lbridge@@$$FUAEXAAUFdBlock@@AAVICodeFunc@@@Z)
1>udm_bridge.obj : error LNK2028: unresolved token (0A00006A) "public: class UMdvect3 __thiscall UMdvect3::operator/(double const &)const " (??KUMdvect3@@$$FQBE?AV0@ABN@Z) referenced in function "public: virtual void __thiscall CM_lbridge::FDLaw(struct FdBlock &,class ICodeFunc &)" (?FDLaw@CM_lbridge@@$$FUAEXAAUFdBlock@@AAVICodeFunc@@@Z)
1>udm_bridge.obj : error LNK2028: unresolved token (0A00006B) "public: class UMdvect3 & __thiscall UMdvect3::operator=(class UMdvect3 const &)" (??4UMdvect3@@$$FQAEAAV0@ABV0@@Z) referenced in function "public: virtual void __thiscall CM_lbridge::FDLaw(struct FdBlock &,class ICodeFunc &)" (?FDLaw@CM_lbridge@@$$FUAEXAAUFdBlock@@AAVICodeFunc@@@Z)
1>udm_bridge.obj : error LNK2028: unresolved token (0A00007B) "public: __thiscall ModelSaveObject::ModelSaveObject(bool)" (??0ModelSaveObject@@$$FQAE@_N@Z) referenced in function "public: void __thiscall ModelSaveObject::`default constructor closure'(void)" (??_FModelSaveObject@@$$FQAEXXZ)
1>udm_bridge.obj : error LNK2028: unresolved token (0A00007C) "public: void __thiscall ModelSaveObject::Initialize(unsigned long,unsigned long,unsigned long)" (?Initialize@ModelSaveObject@@$$FQAEXKKK@Z) referenced in function "public: virtual char const * __thiscall CM_lbridge::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@CM_lbridge@@$$FUAEPBDPAUModelSaveObject@@@Z)
1>udm_bridge.obj : error LNK2028: unresolved token (0A00007D) "public: void __thiscall ModelSaveObject::Save(unsigned long,bool &)" (?Save@ModelSaveObject@@$$FQAEXKAA_N@Z) referenced in function "public: virtual char const * __thiscall CM_lbridge::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@CM_lbridge@@$$FUAEPBDPAUModelSaveObject@@@Z)
1>udm_bridge.obj : error LNK2028: unresolved token (0A00007E) "public: void __thiscall ModelSaveObject::Save(unsigned long,int &)" (?Save@ModelSaveObject@@$$FQAEXKAAH@Z) referenced in function "public: virtual char const * __thiscall CM_lbridge::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@CM_lbridge@@$$FUAEPBDPAUModelSaveObject@@@Z)
1>udm_bridge.obj : error LNK2028: unresolved token (0A00007F) "public: void __thiscall ModelSaveObject::Save(unsigned long,double &)" (?Save@ModelSaveObject@@$$FQAEXKAAN@Z) referenced in function "public: virtual char const * __thiscall CM_lbridge::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@CM_lbridge@@$$FUAEPBDPAUModelSaveObject@@@Z)
1>udm_bridge.obj : error LNK2019: unresolved external symbol "public: __thiscall ModelSaveObject::ModelSaveObject(bool)" (??0ModelSaveObject@@$$FQAE@_N@Z) referenced in function "public: void __thiscall ModelSaveObject::`default constructor closure'(void)" (??_FModelSaveObject@@$$FQAEXXZ)
1>udm_bridge.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall ContactModel::~ContactModel(void)" (??1ContactModel@@$$FUAE@XZ) referenced in function "public: virtual __thiscall CM_lbridge::~CM_lbridge(void)" (??1CM_lbridge@@$$FUAE@XZ)
1>udm_bridge.obj : error LNK2001: unresolved external symbol "public: virtual double & __thiscall ContactModel::Property(int)" (?Property@ContactModel@@UAEAANH@Z)
1>udm_bridge.obj : error LNK2019: unresolved external symbol "public: void __thiscall UMdvect3::Fill(double)" (?Fill@UMdvect3@@$$FQAEXN@Z) referenced in function "public: void __thiscall CM_lbridge::CheckBonding(struct FdBlock &,class ICodeFunc &)" (?CheckBonding@CM_lbridge@@$$FQAEXAAUFdBlock@@AAVICodeFunc@@@Z)
1>udm_bridge.obj : error LNK2019: unresolved external symbol "public: void __thiscall ModelSaveObject::Save(unsigned long,int &)" (?Save@ModelSaveObject@@$$FQAEXKAAH@Z) referenced in function "public: virtual char const * __thiscall CM_lbridge::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@CM_lbridge@@$$FUAEPBDPAUModelSaveObject@@@Z)
1>udm_bridge.obj : error LNK2019: unresolved external symbol "public: void __thiscall ModelSaveObject::Save(unsigned long,double &)" (?Save@ModelSaveObject@@$$FQAEXKAAN@Z) referenced in function "public: virtual char const * __thiscall CM_lbridge::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@CM_lbridge@@$$FUAEPBDPAUModelSaveObject@@@Z)
1>udm_bridge.obj : error LNK2019: unresolved external symbol "public: void __thiscall ModelSaveObject::Save(unsigned long,bool &)" (?Save@ModelSaveObject@@$$FQAEXKAA_N@Z) referenced in function "public: virtual char const * __thiscall CM_lbridge::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@CM_lbridge@@$$FUAEPBDPAUModelSaveObject@@@Z)
1>udm_bridge.obj : error LNK2019: unresolved external symbol "public: void __thiscall ModelSaveObject::Initialize(unsigned long,unsigned long,unsigned long)" (?Initialize@ModelSaveObject@@$$FQAEXKKK@Z) referenced in function "public: virtual char const * __thiscall CM_lbridge::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@CM_lbridge@@$$FUAEPBDPAUModelSaveObject@@@Z)
1>udm_bridge.obj : error LNK2019: unresolved external symbol "public: virtual char const * __thiscall ContactModel::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@ContactModel@@$$FUAEPBDPAUModelSaveObject@@@Z) referenced in function "public: virtual char const * __thiscall CM_lbridge::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@CM_lbridge@@$$FUAEPBDPAUModelSaveObject@@@Z)
1>udm_bridge.obj : error LNK2019: unresolved external symbol "public: class UMdvect3 & __thiscall UMdvect3::operator=(class UMdvect3 const &)" (??4UMdvect3@@$$FQAEAAV0@ABV0@@Z) referenced in function "public: virtual void __thiscall CM_lbridge::FDLaw(struct FdBlock &,class ICodeFunc &)" (?FDLaw@CM_lbridge@@$$FUAEXAAUFdBlock@@AAVICodeFunc@@@Z)
1>udm_bridge.obj : error LNK2019: unresolved external symbol "public: class UMdvect3 __thiscall UMdvect3::operator/(double const &)const " (??KUMdvect3@@$$FQBE?AV0@ABN@Z) referenced in function "public: virtual void __thiscall CM_lbridge::FDLaw(struct FdBlock &,class ICodeFunc &)" (?FDLaw@CM_lbridge@@$$FUAEXAAUFdBlock@@AAVICodeFunc@@@Z)
1>udm_bridge.obj : error LNK2019: unresolved external symbol "public: void __thiscall UMdvect3::operator-=(class UMdvect3 const &)" (??ZUMdvect3@@$$FQAEXABV0@@Z) referenced in function "public: virtual void __thiscall CM_lbridge::FDLaw(struct FdBlock &,class ICodeFunc &)" (?FDLaw@CM_lbridge@@$$FUAEXAAUFdBlock@@AAVICodeFunc@@@Z)
1>udm_bridge.obj : error LNK2019: unresolved external symbol "public: class UMdvect3 __thiscall UMdvect3::operator*(double const &)const " (??DUMdvect3@@$$FQBE?AV0@ABN@Z) referenced in function "public: virtual void __thiscall CM_lbridge::FDLaw(struct FdBlock &,class ICodeFunc &)" (?FDLaw@CM_lbridge@@$$FUAEXAAUFdBlock@@AAVICodeFunc@@@Z)
1>udm_bridge.obj : error LNK2019: unresolved external symbol "public: __thiscall ContactModel::ContactModel(unsigned long,bool)" (??0ContactModel@@$$FQAE@K_N@Z) referenced in function "public: __thiscall CM_lbridge::CM_lbridge(bool,class ICodeFunc *)" (??0CM_lbridge@@$$FQAE@_NPAVICodeFunc@@@Z)
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Simulation\Itasca\CPP Code\udm_bridge\Debug\udm_bridge.exe : fatal error LNK1120: 28 unresolved externals
1>Build log was saved at "file://c:\Simulation\Itasca\CPP Code\udm_bridge\udm_bridge\Debug\BuildLog.htm"
1>udm_bridge - 29 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Is This A Good Question/Topic? 0
  • +

Replies To: Linking error LNK2019: unresolved external symbol

#2 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1371
  • View blog
  • Posts: 4,750
  • Joined: 19-February 09

Re: Linking error LNK2019: unresolved external symbol

Posted 02 April 2012 - 04:00 PM

The first error says the linker can't find the ContactModel::SaveRestore function. If it is in an implementation file (.cpp), you will need to add the file to the project.
Was This Post Helpful? 0
  • +
  • -

#3 saggio  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 02-April 12

Re: Linking error LNK2019: unresolved external symbol

Posted 03 April 2012 - 01:29 AM

#define:

Hmmm... As far as I know the ContactModel::SaveRestore function is available in the cpp code I attached? And that is the only cpp that is supposed to be included in the project...
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6081
  • View blog
  • Posts: 23,557
  • Joined: 23-August 08

Re: Linking error LNK2019: unresolved external symbol

Posted 03 April 2012 - 02:51 AM

udm_bridge.obj : error LNK2028: unresolved token (0A00005F) "public: virtual char const * __thiscall ContactModel::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@ContactModel@@$$FUAEPBDPAUModelSaveObject@@@Z) referenced in function "public: virtual char const * __thiscall CM_lbridge::SaveRestore(struct ModelSaveObject *)" (?SaveRestore@CM_lbridge@@$$FUAEPBDPAUModelSaveObject@@@Z)

Notice the difference in the class names I've bolded. The method you show is the CM_lbridge method, but the linker can't find the parent's method in ContactModel.
Was This Post Helpful? 1
  • +
  • -

#5 saggio  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 02-April 12

Re: Linking error LNK2019: unresolved external symbol

Posted 03 April 2012 - 03:14 AM

Thanks for your help this far.

ContactModel resides in the cmodel.h file which is attached to the project and declared in the cpp.
It looks like this:

class ContactModel {
  private:
    unsigned long ulType;
  protected:
    bool delete_flag;
    bool must_overlap;
  public:
    EXPORT virtual ContactModel *Clone(ICodeFunc *cf=0) const=0;
      // Return a new instance of this udm.
    EXPORT void                  SetDelete(bool bIn) { delete_flag = bIn; }
      // If true, then the contact may be deleted at the discretion of PFC;
      // otherwise, the contact will not be deleted, even if gap is huge.
    EXPORT void                  MustOverlap(bool bIn) { must_overlap = bIn; }
      // If true, then the contact will be inactive and FDLaw() will not be called
      // unless the two contacting entities have a positive overlap.  While
      // inactive the contact force and moment will be zero, and most of the
      // contact quantities (including position and unit normal) will not
      // be updated.  Setting this flag to true will speed up the computations.
      // If some sort of interaction must occur (e.g., the contact is bonded),
      // then set this flag to false.
    EXPORT virtual const char   *Name(void) const=0;
      // Return contact model name.
    EXPORT virtual const char  **PropNames(void) const=0;
      // Return array of property-name strings.
    EXPORT virtual double        ReturnProp(int n) const=0;
      // Return value of property (n) associated with array in PropNames.
    EXPORT virtual void          AcceptProp(int n, double v)=0;
      // Receive value of property (n) associated with array in PropNames,
      // and store this value locally.
    EXPORT virtual double        KnEstimate(void) const=0;
    EXPORT virtual double        KsEstimate(void) const=0;
      // Return estimate of normal & shear tangent stiffness,
      // to be used by PFC if no other sources of stiffness information
      // exist, in order to estimate an initial timestep.
    EXPORT virtual unsigned long Version(void) const = 0;
      // Return version number of this udm.  May be used to restore files
      // containing earlier versions of the udm, which may omit some variables.
    EXPORT virtual const char   *PreCycle(ICodeFunc &cf)=0;
      // Will be called at the start of a set of cycles.  May be used to 
      // re-initialize internal data.  If error, then return string with
      // error message, else return 0.
    EXPORT virtual void          FDLaw(FdBlock &fb, ICodeFunc &cf)=0;
      // Will be called during the force-displacement law of the DEM
      // computation.  Must update: contact force, contact moment, and
      // current value of normal and shear stiffness.
    EXPORT virtual const char   *SaveRestore(ModelSaveObject *mso);
      // Called by PFC when the SAVE/RESTORE commands are given.  May be used
      // to save/restore internal data consisting of real, integer and
      // boolean types.  If error, then return string with error message, else
      // return 0.
    EXPORT virtual bool          TransferProps(const ContactModel &cm, bool reverse=false) {return false;}
      // Used by the Periodic Space logic to transfer contact model properties from cm to this instance 
      // (both instances are assumed to be of same type). The reverse flag means that the normal of the 
      // contacts are in opposite directions. Returns false by default, in which case
      // an error is thrown indicating that the contact model does not handle the Periodic Space logic. 
      // May be overriden to properly transfer the contact properties and return true, in which case the
      // error mentioned above will be turned off.

    // *** Following entry points usually not used by user.
    EXPORT          ContactModel(unsigned long ulTypeIn, bool bRegister=false);
    EXPORT virtual ~ContactModel(void);
    EXPORT bool                       OKtoDelete(void)  const { return delete_flag; }
    EXPORT bool                       MustOverlap(void) const { return must_overlap; }
    EXPORT unsigned long              Type(void)        const { return ulType; }
    EXPORT int                        NameToIndex(const char *strName) const;
    EXPORT const char                *GetPropName(int) const;
    EXPORT virtual double            &Property(int);
    EXPORT virtual void               remap(ICodeFunc &) { }
    //
    EXPORT static unsigned long       NumModels(void);
    EXPORT static const ContactModel *GetModel(unsigned long ulPos);
    EXPORT static const ContactModel *ContactModel::FindByType(unsigned long ulType_in);
    EXPORT static bool                IsCprop(const char *strName);
    EXPORT static const char         *Load(const char *strLibPathAndName,bool &);
};



I have tried removing and then reattaching cmodel.h to the project, but I still have the same problem.
Was This Post Helpful? 0
  • +
  • -

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6081
  • View blog
  • Posts: 23,557
  • Joined: 23-August 08

Re: Linking error LNK2019: unresolved external symbol

Posted 03 April 2012 - 03:35 AM

Is there an implementation of ContactModel::SaveRestore() -- as well as the other missing methods -- in a .cpp file? Is that file part of your project and therefore being compiled?
Was This Post Helpful? 1
  • +
  • -

#7 saggio  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 02-April 12

Re: Linking error LNK2019: unresolved external symbol

Posted 03 April 2012 - 03:57 AM

View PostJackOfAllTrades, on 03 April 2012 - 03:35 AM, said:

Is there an implementation of ContactModel::SaveRestore() -- as well as the other missing methods -- in a .cpp file? Is that file part of your project and therefore being compiled?


The cpp I attached in the first post is the only one. However, ContactModel is also declared in another header file, udmlbridge.h:

#ifndef __CMODEL_LBRIDGE_H
#define __CMODEL_LBRIDGE_H

#ifndef __CMODEL_H
#include "cmodel.h"
#endif

// User-defined contact model "udm_lbridge"
class CM_lbridge : public ContactModel {
  private:
    double kn_load;     // normal stiffness at loading
    double kn_unload;   // normal stiffness at unloading
    double kn_m;        // mean normal stiffness
    double ks;          // shear stiffness
    double fric;        // frictional coefficient
    int    bmode; // bond mode = 0, not bonded & never failed
                  //             1, not bonded & failed in tension
                  //                invokes fc_udm( 0 )
                  //             2, not bonded & failed in shear
                  //                invokes fc_udm( 1 )
                  //             3, bonded
    double lb_nstr;    // normal contact strength
    double lb_sstr;    // shear contact strength
    bool   bObj2IsBall;
    double sp_damp;     // ratio k_load/k_unload <= 1.0, 0.8 default resti. coef = 0.9
    double u_old;       // overlap just before
    double u_zero;      // default overlap when reloading within this contact cycle
    double u_zeroo;     // default overlap when unloading within this contact cycle
    double u_max;       // max. overlap of this contact cycle
    double n_force_old; // n_force just before to check transition + -
    bool   bNtension;   // FDLaw option, with or without tensile force, default bFalse (with tensile)
    bool   bInheritProp;// Inherit property in contact class, default bFalse (NOT inherit)

  public:
    EXPORT  CM_lbridge( bool bRegister=false, ICodeFunc *cf=0 );
    EXPORT ~CM_lbridge(void) { }
    EXPORT ContactModel *Clone( ICodeFunc *cf=0 ) const
      { return new CM_lbridge(false, cf); }
    //
    EXPORT const char   *Name(void) const;
    EXPORT const char  **PropNames(void) const;
    EXPORT double        ReturnProp(int n) const;
    EXPORT void          AcceptProp(int n, double v);
    EXPORT double        KnEstimate(void) const { return kn_unload; }
    EXPORT double        KsEstimate(void) const { return ks; }
    EXPORT unsigned long Version(void) const { return 5; }
    EXPORT const char   *PreCycle(ICodeFunc &cf);
    EXPORT void          FDLaw(FdBlock &fb, ICodeFunc &cf);
    EXPORT const char   *SaveRestore(ModelSaveObject *mso);
    //
    void SetProp(ICodeFunc &cf);
    void SetKn(void);
    void CheckBonding(FdBlock &fb, ICodeFunc &cf);
};



This file is also added to the project and included in the main (and only) cpp.
Was This Post Helpful? 0
  • +
  • -

#8 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6081
  • View blog
  • Posts: 23,557
  • Joined: 23-August 08

Re: Linking error LNK2019: unresolved external symbol

Posted 03 April 2012 - 04:05 AM

Header files only contain the class definition. The implementation -- the actual function themselves -- are in a .cpp file, or if this is a static library, in a .lib file which must be added to the list of libraries to link into the code.

Is there no documentation with this software? I gather from what I can find there is probably an expectation that a beginner is not using this. If it's not as simple as linking a library, you might have better luck seeking support from the vendor.

From the apparent vendor's support page:

Quote

Where is the "Knowledge Base?"; Why not more "FAQs?"

Extensive "Knowledge Bases" and FAQs constitute the "free" portion of a software vendor's support policy; usually, to speak with support personnel is a pay-per-event process. Itasca software is supported in a free, person-to-person manner (see the Support Policy for a complete statement). As a result, there is no need for extensive internet-based support documentation. The information provided in the FAQs available here focuses on two areas: critical code operation issues (startup, keys, installation, etc.) whose resolution should not be delayed by having to wait for communication during normal business hours, and topics of occasional interest that are not immediately proper to the codes themselves (handling plots or making animations, for instance — two subjects described on the Miscelleneous page.).

This post has been edited by JackOfAllTrades: 03 April 2012 - 04:06 AM

Was This Post Helpful? 1
  • +
  • -

#9 saggio  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 02-April 12

Re: Linking error LNK2019: unresolved external symbol

Posted 04 April 2012 - 12:02 AM

JackOfAllTrades:
Yes, you correctly identified the vendor, and I've been in contact with them too. They suggested that I should test compiling one of their more simple tutorial models (which is ridiculously simple if you ask me). I did and that worked fine. Then there are additional models available on their webpage but not developed by the vendor, and thus not supported either. The code I work with here is one of those models. I dont know what to make of it, but shortly after being in contact with them regarding my problems they removed ALL user defined models from their homepage, including the one I'm testing? :)

Since I assume the code itself is correct, this seems to be either a problem putting the project togeter or a compiler problem (wrong settings). If anyone has input in that direction I still appreciate the help! Otherwise perhaps I should move on to less complex models...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1