关于使用c++链接的时候出现异常的问题,急~~在线等~~

Donnki 2009-03-26 10:29:22
下面这段代码是直接从Xerces-C++的教程中拷出来的:1.cpp

#include <xercesc/util/PlatformUtils.hpp>
// Other include files, declarations, and non-Xerces-C++ initializations.

using namespace xercesc;

int main(int argc, char* argv[])
{
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
// Do your failure processing here
return 1;
}

// Do your actual work with Xerces-C++ here.

XMLPlatformUtils::Terminate();

// Other terminations and cleanup.
return 0;
}


在sunOS 5.8运行以下命令
#g++ -I /u1/app/liuyi/xerces-c-3.0.1-sparc-solaris-cc-5.7/include 1.cpp

出现下面这样的异常:
Undefined first referenced
symbol in file
typeinfo for xercesc_3_0::XMLException/var/tmp//cc21XuM6.o
xercesc_3_0::XMLPlatformUtils::Initialize(char const*, char const*, xercesc_3_0::PanicHandler*, xercesc_3_0::MemoryManager*)/var/tmp//cc21XuM6.o
xercesc_3_0::XMLUni::fgXercescDefaultLocale /var/tmp//cc21XuM6.o
xercesc_3_0::XMLPlatformUtils::Terminate() /var/tmp//cc21XuM6.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status


----------------------
请问各位C++的大侠们这是怎么回事?应该怎么解决???很急,在线等
...全文
230 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
jack19800302 2009-03-29
  • 打赏
  • 举报
回复
出错信息:
>make -f makefile_t1
xlC_r -I/tuxedo/tuxedo8.1/include -I../ -g -w -DD64 -q64 -c t1.C
xlC_r -g -w -DD64 -q64 -L/home/tips/conv/lib/l64/xerces-c24.0.so -o t1 t1.o
ld: 0711-317 ERROR: Undefined symbol: .XMLPlatformUtils::Initialize()
ld: 0711-317 ERROR: Undefined symbol: .XMLPlatformUtils::Terminate()
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make: The error code from the last command is 8.
jack19800302 2009-03-29
  • 打赏
  • 举报
回复
我也碰到这个问题了,我的是aix5.3 我已连接库里,楼主是怎么解决的
附上我的代码,各位帮帮忙


#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/TransService.hpp>
#include <xercesc/parsers/SAXParser.hpp>
#include <xercesc/framework/MemBufInputSource.hpp>
#include <fstream.h>
#include <string.h>
#include <strings.h>

main(int argc, char *argv[])
{
unsigned long duration;
const char* xmlFile = 0;
char localeStr[64];
memset(localeStr, 0, sizeof localeStr);

if (argc < 2){
cout<<" Enter input XML file as parameter. \n";
return 1;
} else {
xmlFile = argv[1];
}

try
{
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch)
{
cerr << "Error during initialization! Message:\n";
return 1;
}

XMLPlatformUtils::Terminate();
}


makefile 如下:
INCDIR=/home/tips/conv//include

CFLAGS= -I/home/tips/conv/include -I../ -g -w -DD64
CC = xlC_r

OBJS =

LIBS = -g -w -L/home/tips/conv/lib -lxerces-c24.0


all: testxml2


testxml2: testxml2.o
$(CC) $(LIBS) -o testxml2 testxml2.o

.C.o:
$(CC) $(CFLAGS) -c $<
.c.o:
$(CC) $(CFLAGS) -c $*.c
clean:
rm -f *.o tc1 tc2
jack19800302 2009-03-29
  • 打赏
  • 举报
回复
我也碰到这个问题了,我的是aix5.3 我已连接库里,楼主是怎么解决的
  • 打赏
  • 举报
回复
先看有没有这些lib先
flameearth 2009-03-26
  • 打赏
  • 举报
回复
没有连接上库 你看看你的Xerces-C++里面link中是不是连接了一些lib
threeleafzerg007 2009-03-26
  • 打赏
  • 举报
回复
很明显没有找到动态链接库
所以链接程序ld 返回错误

需要指定 -L
icecools 2009-03-26
  • 打赏
  • 举报
回复
XMLPlatformUtils::Initialize(char const*, char const*, xercesc_3_0::PanicHandler*, xercesc_3_0::MemoryManager*)
看起来这个函数有好多参数啊,你的程序里好像没有?
downmooner 2009-03-26
  • 打赏
  • 举报
回复
估计没链接库
hai040 2009-03-26
  • 打赏
  • 举报
回复
函数没定义
没链接PlatformUtils的相关库
-l?

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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