首页 > 编程知识 正文

etc安装教程(Fastdb安装与使用)

时间:2023-05-05 12:01:50 阅读:121314 作者:4655

环境: CentOS 6.4 32位

注意:

64位运行有问题,最后运行segmentation fault,因此最后采用32位操作系统。

1.1安装苹果的年轻人(1)安装所需的依赖

yum install gcc make gcc-c wget苹果集团(2)下载源代码

wget 3358 www.garret.ru/fastdb-3.76.tar.gz苹果年轻人(3)解冻

切换到tar -xvf fastdb-3.76.tar.gz苹果集团(4)目录

cd fastdb苹果组(5)配置安装目录/opt/fastdb

./configure---- prefix=/opt/fastdb苹果组(6)编译

make -j16苹果的小伙(7)安装

make install苹果小伙(8)注意事项

在Linux上运行程序的提示:

incompatibilitybetweenheadersandlibrary

fastdb假设大多数Linux版本都是64位。 如果计算机为32位,则必须注释掉config.h文件中的以下内容:

//#if! efined(win32 )|defined (win64 )//most unixes are now 64-bit,while 32-bitwindowsisstillquitepopular苹果小伙(/# )

1.2要配置苹果的组,程序必须设置库的路径,才能成功找到库文件。

(1)打开文件

VI/etc/LD.so.conf.d/fast CB _ libs.conf苹果组(2)添加fast动态库路径

/opt/fastdb/lib苹果小伙(3) APP应用立即生效

检查sudo /sbin/ldconfig苹果小伙(4)是否有效

ldconfig -v | grep 'fastdb '

2.1简单示例(1)代码

# include ' fastdb.h ' # include stdio.huse _ fastdb _ namespaceclassrecord { public 3360 record { }~record { }//id是主键(; 创建记录数据表Register(Record )的const int g_Records=5; //! 数据void insertRecord () {printf(#####insertrecord#####n ) }; for(int4I=1; i g_Records; I ) {记录rec; rec.id=i; rec.value=i * i; printf(%d----%dn )、rec.id、rec.value ); //数据insert (插入rec; (//! 数据void更新器() { printf (# # # # #更新器# # #n ) }; dbcursorrecordcursorwrite (dbcursorforupdate; //写入光标对象dbcursorforupdateintn=cursor write.select (; //查询//存在记录,加1更新if(0n ) do ) cursor write-value=cursor write-value 1; cursorWrite.update (; }while(cursorwrite.next ) ); //next ()光标向后滚动)//! 记录voidremoverecord(constintid ) printf ) ' #####removerecord####n ' ); dbQuery q; //查询语句dbcursorrecordcursorwrite (dbcursorforupdate; //写入光标对象dbCursorForUpdate q='id=',id; intn=cursorwrite.select(q; //查询//存在记录if(0n ) do ) cursorwrite.removeallselected ); }while(cursorwrite.next ) ); //next ()光标向后滚动)//! 所有数据void removeAllRecord () (printf (# # # # # remove all record # # #n ) ); dbcursorrecordcursorwrite (dbcursorforupdate; //写入光标对象dbcursorforupdatecursorwrite.remove all (; //这里清除。 不清除的话会累计} //! 查询数据voidselectrecord ({ printf (# # # # select record # # # #n ) }; dbCursorRecord cursorRead; //只读光标对象int n=cursorRead.select (; //联系我//记录if(0n ) do ) printf(%d----%d(%dn ),n,cursorRead-id,cursorRead-value ); }while(cursorread.next ) ); //next ()向后滚动光标intmain(intargc,char* argv[] ) { db数据库数据库数据库; //数据库testparif(db.open ) _t ) ' testpar ) ) /插入数据insertRecord ); 提交数据库.com MIT (; //查询数据selectRecord (; //在更新数据中加入1 updateRecord (; 提交数据库.com MIT (; //查询数据selectRecord (; //删除数据removerecord(1; 提交数据库.com MIT (; //查询数据selectRecord (; //删除所有数据removeAllRecord (; 提交数据库.com MIT (; //查询数据selectRecord (; //关闭数据库db.close (; }返回0; (2)编译

g example.CPP-o example-I/opt/fastdb/include/fastdb-l/opt/fastdb/Li B- lfastdb (3)的执行结果

如果执行有问题,请确认注意事项

[ root @ live CD example ] #./example # # # # insert record # # #1----12---43---94-- 16 # # # #1--- - #4---1----24---2---54----3----33----2-- 53---3-- 103---4-- 4

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。