求助!如何解决这个连接错误error LNK2019

Jhill 2008-12-19 08:21:08
各位大侠:
我碰到一个连接错误:
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();
}

折腾了一天,一点头绪都找不到。

敬请各位赐教!谢谢!
...全文
268 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ccpaishi 2008-12-19
  • 打赏
  • 举报
回复
楼主是不是没有包含静态库,或者没有把头文件包含在工程中
ndchenxiaofeng 2008-12-19
  • 打赏
  • 举报
回复
删除文件,重新编译~
菜牛 2008-12-19
  • 打赏
  • 举报
回复 1
添加Rpcrt4.lib库到链接中。
用户 昵称 2008-12-19
  • 打赏
  • 举报
回复
可能函数声明与实现有冲突了。
  • 打赏
  • 举报
回复
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
}
函数可以这样写?头一次见到

16,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧