各位大侠:
我碰到一个连接错误:
opennurbs_staticd.lib(opennurbs_uuid.obj) : error LNK2019: unresolved external symbol __imp__UuidCreate@4 referenced in function "bool __cdecl ON_CreateUuid(struct _GUID &)" (?ON_CreateUuid@@YA_NAAU_GUID@@@Z)。 opennurbs_staticd.lib是第三方库,有源码,其中opennurbs_uuid.cpp的源码是:#include "opennurbs.h"
#if defined(ON_UUID_DECLARED_AS_CLASS)
bool ON_UUID::operator==(const ON_UUID& other) const
{
  return (0==memcmp(this,&other,sizeof(*this)));
}bool ON_UUID::operator!=(const ON_UUID& other) const
{
  return (0!=memcmp(this,&other,sizeof(*this)));
}#endif// used to map the correspondence between uuid strings and
// ON_UUIDs as an array of 16 bytes.// for little endian CPUs (Intel, etc)
static const int little_endian_rho[16] = {3,2,1,0, 5,4, 7,6, 8,9, 10,11,12,13,14,15};// for big endian CPUs (Motorola, MIPS, Sparc, etc.)
static const int big_endian_rho[16] = {0,1,2,3, 4,5, 6,7, 8,9, 10,11,12,13,14,15}; 
bool ON_CreateUuid( ON_UUID& new_uuid )
{
#if defined(ON_OS_WINDOWS)
  // Header: Declared in Rpcdce.h.
  // Library: Use Rpcrt4.lib  
  ::UuidCreate(&new_uuid);
  //::UuidCreateSequential(&new_uuid);
  return true;
#elif defined(ON_COMPILER_XCODE)
  // Header: #include <uuid/uuid.h>
  uuid_generate((unsigned char*)&new_uuid);
  return true;
#else
  // You must supply a way to create unique ids or you 
  // will not be able to write 3dm files.
  memset(&new_uuid,0,sizeof(ON_UUID));
  return false;
#endif

ON_UUID ON_UuidFromString( const char* sUUID )
{
  static const int* rho = ( ON::big_endian == ON::Endian() ) 
                        ? big_endian_rho 
                        : little_endian_rho;  union 
  {
    ON_UUID uuid;
    unsigned char b[16];
  } u;
  BOOL bFailed;
  int bi, ci;
  unsigned char c;
  unsigned char byte_value[2];  for ( bi = 0; bi < 16; bi++ ) 
    u.b[bi] = 0;  bFailed = sUUID ? FALSE : TRUE;  if ( !bFailed ) {
    while ( *sUUID && *sUUID <= ' ' ) // skip leading white space
      sUUID++;
    if ( *sUUID == '{' )
      sUUID++;
    for ( bi = 0; bi < 16; bi++ ) {
      ci = 0;
      byte_value[0] = 0;
      byte_value[1] = 0;
      while ( ci < 2 ) {
        c = *sUUID++;
        if ( !c ) {
          bFailed = TRUE;
          break;
        }
        if ( c >= 'A' && c <= 'F' ) {
          byte_value[ci++] = (c-'A'+10);
        }
        else if ( c >= '0' && c <='9' ) {
          byte_value[ci++] = (c-'0');
        }
        else if ( c >= 'a' && c <= 'f' ) {
          byte_value[ci++] = (c-'a'+10);
        }
        else if ( c != '-' ) {
          bFailed = TRUE;
          break;
        }
      }
      if ( bFailed )
        break;
      u.b[rho[bi]] = 16*byte_value[0] + byte_value[1];
    }
  }  if ( bFailed ) {
    u.uuid = ON_nil_uuid;
  }  return u.uuid;
}
ON_UUID ON_UuidFromString( const wchar_t* sUUID )
{
  wchar_t w;
  char s[64];
  int i;
  while ( *sUUID && *sUUID <= ' ' ) // skip leading white space
    sUUID++;
  if ( *sUUID == '{' )
    sUUID++;
  i = 0;
  while (i < 63 )
  {
    w = *sUUID++;
    if ( w >= 'A' && w <= 'F' )
      s[i++] = (char)w;
    else if ( w >= '0' && w <='9' )
      s[i++] = (char)w;
    else if ( w >= 'a' && w <= 'f' )
      s[i++] = (char)w;
    else if ( w != '-' ) 
      break;
  }
  s[i] = 0;  return ON_UuidFromString(s);}
 
ON_UuidIndex::ON_UuidIndex()
{
  memset(this,0,sizeof(*this));
}int ON_UuidIndex::CompareIdAndIndex( const ON_UuidIndex* a, const ON_UuidIndex* b )
{
  int i;
  if ( !a )
    return (b ? -1 : 0 );
  if ( !b )
    return 1;  // compare id first
  if ( 0 == (i = ON_UuidCompare(&a->m_id,&b->m_id)) )
    i = a->m_i - b->m_i;  return i;
}int ON_UuidIndex::CompareIndexAndId( const ON_UuidIndex* a, const ON_UuidIndex* b )
{
  int i;
  if ( !a )
    return (b ? -1 : 0 );
  if ( !b )
    return 1;  // compare index first
  if ( 0 == (i = a->m_i - b->m_i) )
    i = ON_UuidCompare(&a->m_id,&b->m_id);  return i;
}int ON_UuidIndex::CompareId( const ON_UuidIndex* a, const ON_UuidIndex* b )
{
  if ( !a )
    return (b ? -1 : 0 );
  if ( !b )
    return 1;
  return ON_UuidCompare(&a->m_id,&b->m_id);
}int ON_UuidIndex::CompareIndex( const ON_UuidIndex* a, const ON_UuidIndex* b )
{
  if ( !a )
    return (b ? -1 : 0 );
  if ( !b )
    return 1;
  return a->m_i - b->m_i;
}
int ON_UuidCompare( const ON_UUID* a, const ON_UUID* b )
{
 
  int rc = 0;
  if ( !a ) 
  {
    return b ? -1 : 0;
  }
  if ( !b )
    return 1;  if ( a->Data1 < b->Data1 ) return -1;
  if ( a->Data1 > b->Data1 ) return  1;  if ( a->Data2 < b->Data2 ) return -1;
  if ( a->Data2 > b->Data2 ) return  1;  if ( a->Data3 < b->Data3 ) return -1;
  if ( a->Data3 > b->Data3 ) return  1;
  return memcmp(a->Data4,b->Data4,sizeof(a->Data4));  return rc;
}
 
int ON_UuidCompare( const ON_UUID& a, const ON_UUID& b)
{
  return ON_UuidCompare(&a,&b);
}bool ON_UuidIsNil( 
        const ON_UUID& uuid 
        )
{
  const ON__INT32* p = (const ON__INT32*)&uuid;
  return ( p[0] || p[1] || p[2] || p[3] ) ? false : true;
}
bool ON_UuidIsNotNil( 
        const ON_UUID& uuid 
        )
{
  const ON__INT32* p = (const ON__INT32*)&uuid;
  return ( p[0] || p[1] || p[2] || p[3] ) ? true : false;
}
char* ON_UuidToString( const ON_UUID& uuid, char* s)
{
  static const char x[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
  static const int addhyphen[16] = {0,0,0,1, 0,1, 0,1, 0,1,  0, 0, 0, 0, 0, 0};
  const unsigned char* b = (const unsigned char*)&uuid;
  char* p;
  int i;
  
  static const int* rho = ( ON::big_endian == ON::Endian() ) 
                        ? big_endian_rho 
                        : little_endian_rho;  unsigned int c;  if ( !s )
    return 0;
  p = s;
  for ( i = 0; i < 16; i++ ) {
    c = b[rho[i]];
    *p++ = x[c>>4];  // purify gripes here if c is an unsigned char - the code runs fine.
    *p++ = x[c&0x0F];
    if ( addhyphen[i] )
      *p++ = '-';
  }
  *p = 0;#if defined(ON_DEBUG)
  {
    ON_UUID u = ON_UuidFromString(s);
    if ( ON_UuidCompare(&u,&uuid) ) {
      ON_ERROR("ON_UuidToString() bug"); // <- breakpoint here
    }
  }
#endif  return s;
}wchar_t* ON_UuidToString( const ON_UUID& uuid, wchar_t* s)
{
  char x[37];
  if ( s && ON_UuidToString(uuid,x) )
  {
    int i;
    for (i = 0; i < 37; i++ )
    {
      s[i] = (wchar_t)x[i];
    }
  }
  else
  {
    s = 0;
  }
  return s;

const char* ON_UuidToString( const ON_UUID& uuid, ON_String& s )
{
  char x[37];
  s = ON_UuidToString( uuid, x );
  return s.Array();

const wchar_t* ON_UuidToString( const ON_UUID& uuid, ON_wString& s )
{
  wchar_t x[37];
  s = ON_UuidToString( uuid, x );
  return s.Array();
}折腾了一天,一点头绪都找不到。 敬请各位赐教!谢谢!

解决方案 »

  1.   

    bool ON_CreateUuid( ON_UUID& new_uuid ) 

    #if defined(ON_OS_WINDOWS) 
      // Header: Declared in Rpcdce.h. 
      // Library: Use Rpcrt4.lib  
      ::UuidCreate(&new_uuid); 
      //::UuidCreateSequential(&new_uuid); 
      return true; 
    #elif defined(ON_COMPILER_XCODE) 
      // Header: #include <uuid/uuid.h> 
      uuid_generate((unsigned char*)&new_uuid); 
      return true; 
    #else 
      // You must supply a way to create unique ids or you 
      // will not be able to write 3dm files. 
      memset(&new_uuid,0,sizeof(ON_UUID)); 
      return false; 
    #endif 

    bool ON_CreateUuid( ON_UUID& new_uuid ) 

    #if defined(ON_OS_WINDOWS) 
      // Header: Declared in Rpcdce.h. 
      // Library: Use Rpcrt4.lib  
      ::UuidCreate(&new_uuid); 
      //::UuidCreateSequential(&new_uuid); 
      return true; 
    #elif defined(ON_COMPILER_XCODE) 
      // Header: #include <uuid/uuid.h> 
      uuid_generate((unsigned char*)&new_uuid); 
      return true; 
    #else 
      // You must supply a way to create unique ids or you 
      // will not be able to write 3dm files. 
      memset(&new_uuid,0,sizeof(ON_UUID)); 
      return false; 
    #endif 

    函数可以这样写?头一次见到