您的位置:首页 > 数据库 > Oracle

error LNK2019: 无法解析的外部符号 "public: virtual __thiscall oracle::occi::SQLException

2013-10-29 23:24 573 查看
右击项目--》选择“属性”--》点开“配置属性”--》点开“连接器”--》点击“输入”,在附加铱赖项中填写“oraocci11d.lib”。

Windows 下进行 OCCI ( Oracle C++ Call Interface ) 开发

Windows下若安装的是Oracle 数据库,则OCCI库文件和头文件在目录 %ORACLE_HOME%\oci 下。

这里采用工具:VS 2005 

(一)基本设置

1. 安装好 oracle instant client

    参见帖子:

2. vs->工具->选项—》解决方案-》vc++-》包含文件 添加:  

$ORACLE_HOME\oci\include

3. vs->工具->选项—》解决方案-》vc++-》库文件 添加:  

$ORACLE_HOME\oci\lib\msvc\vc8

4. 右键项目-》属性-》配置属性-》连接器-》输入-》附加依赖项 添加  

oraocci11d.lib  

5 重启vs 就ok了;

(二)错误集锦

1. 运行时提示,“无法启动此程序,因为计算机中丢失 OCI.dll”

复制 C:\oracle10g\product\10.2.0\db_1\BIN 下的 OCI.dll 到DEBUG目录,与 exe 文件放在一起。

2. 编译时出现链接错误

1>------ 已启动生成: 项目: TaxServer, 配置: Debug Win32 ------

1>正在链接...

1>   正在创建库 E:\TaxServer\Debug\TaxServer.lib 和对象 E:\TaxServer\Debug\TaxServer.exp

1>DBwrapper.obj : error LNK2019: 无法解析的外部符号 "public: virtual __thiscall oracle::occi::SQLException::~SQLException(void)" (??1SQLException@occi@oracle@@UAE@XZ),该符号在函数 __catch$?open@DBwrapper@@QAE_NXZ$0 中被引用

1>DBwrapper.obj : error LNK2019: 无法解析的外部符号 "public: virtual int __thiscall oracle::occi::SQLException::getErrorCode(void)const " (?getErrorCode@SQLException@occi@oracle@@UBEHXZ),该符号在函数 __catch$?open@DBwrapper@@QAE_NXZ$0 中被引用

1>DBwrapper.obj : error LNK2019: 无法解析的外部符号 "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall oracle::occi::SQLException::getMessage(void)const " (?getMessage@SQLException@occi@oracle@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ),该符号在函数
__catch$?open@DBwrapper@@QAE_NXZ$0 中被引用

1>DBwrapper.obj : error LNK2019: 无法解析的外部符号 "public: static class oracle::occi::Environment * __cdecl oracle::occi::Environment::createEnvironment(enum oracle::occi::Environment::Mode,void *,void * (__cdecl*)(void *,unsigned int),void * (__cdecl*)(void *,void
*,unsigned int),void (__cdecl*)(void *,void *))" (?createEnvironment@Environment@occi@oracle@@SAPAV123@W4Mode@123@PAXP6APAX1I@ZP6APAX11I@ZP6AX11@Z@Z),该符号在函数 "public: bool __thiscall DBwrapper::open(void)" (?open@DBwrapper@@QAE_NXZ) 中被引用

1>DBwrapper.obj : error LNK2019: 无法解析的外部符号 "public: static void __cdecl oracle::occi::Environment::terminateEnvironment(class oracle::occi::Environment *)" (?terminateEnvironment@Environment@occi@oracle@@SAXPAV123@@Z),该符号在函数 "public: bool __thiscall DBwrapper::close(void)"
(?close@DBwrapper@@QAE_NXZ) 中被引用

1>E:\TaxServer\Debug\TaxServer.exe : fatal error LNK1120: 5 个无法解析的外部命令

1>生成日志保存在“file://e:\TaxServer\Debug\BuildLog.htm”

1>TaxServer - 6 个错误,0 个警告

========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

细看,发现只是有些地方出现链接错误,例如 SQLException,发现是程序原因,

老版本,VC7下编译通过的程序,在VC9下不能通过。

将 

try {

    } catch (SQLException& ex) {

    }

改成

try {

    } catch (SQLException ex) {

    }

(三)问题

VS 2005 和 VS 2008 均编译未通过 Oracle Instant Client win-x86-64-11.1.0.7.0,待解决问题.

OCCI for VC9 下载地址:http://www.oracle.com/technetwork/database/occidownloads-083553.html

(四)参考

VS2008中用OCCI连接Oracle,不需要安装Oracle客户端 http://hi.baidu.com/nlpack/blog/item/b3b9a3fe57f6921a08244d65.html

VS2008 C++连接oracle 客户端的问题 http://hi.baidu.com/%D1%E3%C9%F9%C1%F4/blog/item/d5bfdca8a327b4bfca130c83.html

Oracle9i中OCCI在VC6下不能DEBUG的问题及解决方法 http://blog.csdn.net/iihero/article/details/1099908
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐