Berkeley Db编译总通不过:undefined reference to 问题

#include <db_cxx.h>
#include <iostream>
#include <cstdlib>
#include <string>
using std::cout;
using std::endl;
using std::string;
int main(int argc, char *argv[]){
        Db db(NULL, 0);
        try{
                db.open(NULL, "firstdb.db", NULL, DB_BTREE, DB_CREATE, 0);
                cout << "The database file has been opend." << endl;
                db.close(0);
        }
        catch(DbException &e){
                cout << "Error has occured while creating the database file." << endl;
        }
        catch(std::exception &e){
                cout << "Unknown error has occured." << endl;
        }
}

 g++ -o first first.cpp出现错误:/tmp/cc24jYcK.o: In function `main':
first.cpp:(.text+0x97): undefined reference to `Db::Db(DbEnv*, unsigned int)'
first.cpp:(.text+0xc5): undefined reference to `Db::open(DbTxn*, char const*, char const*, DBTYPE, unsigned int, int)'
first.cpp:(.text+0xf2): undefined reference to `Db::close(unsigned int)'
first.cpp:(.text+0x1c8): undefined reference to `Db::~Db()'
first.cpp:(.text+0x1e8): undefined reference to `Db::~Db()'
/tmp/cc24jYcK.o:(.gcc_except_table+0x2c): undefined reference to `typeinfo for DbException'
collect2: ld returned 1 exit status

g++ -o first first.cpp -L/usr/local/BerkeleyDB.4.2/lib/也不行.
怎么解决?
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值