dbTalk Databases Forums  

Which lib to link

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss Which lib to link in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jack
 
Posts: n/a

Default Which lib to link - 02-22-2006 , 01:52 AM






I've been searching in all directories. It isn't prominent to find
which library files I have to pass to the Linker.
g++ -o db db_try.cpp -l?????

Please fill in the question marks.
Thanks
Jack


Reply With Quote
  #2  
Old   
Jack
 
Posts: n/a

Default Re: Which lib to link - 02-22-2006 , 09:16 PM






Now, I finally got thru the compiler. Now facing the linker again
Seems like even the Db:b(...) isn't correctly linked.
g++ -o try db_try.cpp -ldb

I've got errors such as Db::set_error_stream undefined reference etc
Why? it should be linked correctly...
Thanks
Jack


Reply With Quote
  #3  
Old   
Jack
 
Posts: n/a

Default Re: Which lib to link - 02-22-2006 , 09:28 PM



Db:b() Typo sorry about that!


Reply With Quote
  #4  
Old   
Jack
 
Posts: n/a

Default Re: Which lib to link - 02-23-2006 , 01:38 AM



There are some examples inside the dir of examples_cxx
Why it's not compiled while on a clean installation?
I saw some files like tag and a folder called getting_started
No exe is found, no makefile
even couldn't compiled using
g++ -o db MyDb.cpp excxx_example_database_read.cpp
excxx_example_database_load.cpp -ldb
Could anyone point me right?
Thanks
Jack


Reply With Quote
  #5  
Old   
Jack
 
Posts: n/a

Default Re: Which lib to link - 02-23-2006 , 07:49 PM



#include <iostream.h>
#include <string>
#include <db_cxx.h>


Db db(NULL, 0);

u_int32_t oFlags = DB_CREATE;

class MyDb
{
public:
MyDb (std::string& path, std::string& dbName, bool isSecondary);
~MyDb() { close(); }

inline Db &getDb() { return db_; }

private:
Db db_;
std::string dbFileName_;
u_int32_t cFlags_;

MyDb() : db_(NULL, 0) { }

void close();
};

MyDb::MyDb (std::string &path, std::string &dbName,
bool isSecondary)
: db_(NULL, 0),
dbFileName_ (path + dbName),
cFlags_ (DB_CREATE)
{
try
{
db_.set_error_stream (&std::cerr);

if (isSecondary)
db_.set_flags (DB_DUPSORT);

db_.open(NULL, dbFileName_.c_str(), NULL, DB_BTREE, cFlags_, 0);
}
catch (DbException &e)
{
std::cerr << "Error opening database: " << dbFileName_ << "\n";
std::cerr << e.what() << std::endl;
}
catch (std::exception &e)
{
std::cerr << "Error opening database: " << dbFileName_ << "\n";
std::cerr << e.what() << std::endl;
}
}





class Plumedata
{
private:
float m_CO;
float m_NOX;
float m_HC;
float m_CO2;
size_t bufLen_;
char databuf_[500];
public:
inline void setCO(float co) { m_CO = co; }
inline void setNOX(float nox) { m_NOX = nox; }
inline void setHC (float hc) { m_HC = hc; }
inline void setCO2 (float co2) { m_CO2 = co2; }

inline float& getCO() { return m_CO; }
inline float& getNOX() { return m_NOX; }
inline float& getHC() { return m_HC; }
inline float& getCO2() { return m_CO2; }
Plumedata() { clear(); }
Plumedata(void *buffer);


void clear();
char *getBuffer();
void show();
};

//void loadPlumeDB( MyDb &, std::string&);

using namespace std;


void Plumedata::clear()
{
m_CO = 0.0;
m_NOX = 0.0;
m_HC = 0.0;
m_CO2 = 0.0;
}

Plumedata::Plumedata(void *buffer)
{
char *buf = (char *)buffer;


m_CO = *((float *)buf);
bufLen_ = sizeof(float);

m_NOX = *((float *)buf);
bufLen_ += sizeof(float);

m_HC = *((float *)buf);
bufLen_ += sizeof(float);

m_CO2 = *((float *)buf);
bufLen_ += sizeof(float);
}

char *Plumedata::getBuffer(void)
{
memset( databuf_ ,0, 500 );
bufLen_ = 0;
int dataLen = 0;

dataLen = sizeof(float);
memcpy (databuf_, &m_CO, dataLen);
bufLen_ += dataLen;

memcpy (databuf_ + bufLen_, &m_NOX, dataLen);
bufLen_ += dataLen;

memcpy (databuf_ + bufLen_, &m_HC, dataLen);
bufLen_ += dataLen;

memcpy (databuf_ + bufLen_, &m_CO2, dataLen);

return (databuf_);

}

void Plumedata::show()
{
std::cout << "\nCO: " << m_CO << std::endl;
std::cout << "NOX: " << m_NOX << std::endl;
std::cout << "HC: " << m_HC << std::endl;
std::cout << "CO2: " << m_CO2 << std::endl;
}

int main (int argc, char *argv[])
{
std::string basename("./");
std::string databasehome("./");

std::string pDbName("Plumedb.db");






}

When you compiled this code, you get link time error!
Thanks
Jack


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.