[cpp] 动态库和静态库加载都遇到了相同问题,内存非法访问!

王继州 wangjzh4701 at tom.com
Wed Nov 15 14:44:01 CST 2006


在使用xercesc和xalanc2个包解析xml时,需要加载2个生成的库文件
#pragma comment(lib,"xerces-c_2.lib")
#pragma comment(lib,"Xalan-C_1.lib")

错误码:0XC0000005:access voilation;

如果把这2个库加入我自己写的test.dll中去,在程序中加载dll时返回的句柄为空,使用GetLastError获取错误码为998,
请各位高手指点下。
以下是我在别人博客上看到的,但他说的解决办法看不明白:{
今天做一个动态库udb_postgresql.dll,开始链接了postgresql的静态库libpq.a.
结果应用程序使用LoadLibrary函数打开udb_postgresql失败,错误代码998(ERROR_NOACCESS).
以为是LoadLibrary的问题,就使用udb_postgresql.lib直接链接到应用程序,结果一运行程序就出现:
the application failed to initialize properly 0xc0000005
最后是换了动态链接libpq.lib和libpq.dll才解决,不知道为什么libpq.a不行,
是否因为它的运行库和我的不一致,导致全局和静态变量初始化失败。}

请各位仗义出手! 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codingnow.com/pipermail/cpp/attachments/20061115/16ade9d0/attachment.html


More information about the Cpp mailing list