[odb-users] l report a bug , and l want to kown how to maping boost.date to the mysql database

冯固海 jme22 at 126.com
Wed Jul 16 22:20:26 EDT 2014


Hello,
   l cant map the boost.date to the mysql database.l have did the next and report a bug:

     There are two cpp at the file system: /home/feng/ODBEXAMPLE
      System:Ubuntu desktop 14.04
      boost version :1.55
-----------------------------------main.cpp--------------------------------------------
#include<odb/database.hxx>
#include<odb/mysql/database.hxx>
#include <cstdlib>
#include<iostream>
#include<string>
#include <odb/transaction.hxx>
#include <memory>
#include </home/feng/ODBEXAMPLE/Person-odb.hxx>
using namespace std;
using namespace odb::core;
int main(int argc, char** argv)
{
    cout<<"feng"<<endl;
    auto_ptr<odb::database>db
    (
          new odb::mysql::database("root","123456","ROSE3")                        //mysql connetion on local at (3306 root 123456 ROSE3)
    );
    Person l("liu",20,1);
    transaction t (db->begin ());
    db->persist (l);
    t.commit ();
    return 0;
}
------------------------------Person.cpp---------------------------------------------
#include <odb/core.hxx>  
#define BOOST_DATA_TIME_SOURCE                           //define the datatime macro
#include<boost/date_time/gregorian/gregorian.hpp>        //load the boost.date library                                        
#include<string>
using namespace std;
using namespace boost::gregorian;
#pragma db object  
class Person
{
public:
    std::string Name;
    int Age;
    int Sex;
    boost::gregorian::date Br;                                              //date
    Person(std::string n,int a,int sex)
    {
        Name=n;
        Age=a;
        Sex=sex;
        Br=date(1993,3,25);
    }
private:
    Person(){};
    friend class odb::access;
  #pragma db id auto   
    unsigned long id_;  
};
---------------------------------------------------------------------------------------------------------------------
the next l compiling  it in the shell:
   odb -d mysql --generate-query --profile boost/date-time Person.cpp
   odb -d mysql --generate-query --generate-schema --profile boost/date-time Person.cpp

the next l load the Person.sql to the mysql database to create a table
all thing gose ok there.

the next l compiling the two cpps use g++:
      g++ -c main.cpp
      g++ -c Person-odb.cxx

the next is link:
     g++ -o main main.o Person-odb.o -lodb-mysql -lodb -lboost_thread -lpthread  -L/usr/local/lib -lboost_system

but  link failed,the output is:
------------------------------Output----------------------
g++: error: main.o: 没有那个文件或目录
g++: error: Person-odb.o: 没有那个文件或目录
feng at feng:/usr/local/lib$ cd
feng at feng:~$ cd /home/feng/ODBEXAMPLE/
feng at feng:~/ODBEXAMPLE$
feng at feng:~/ODBEXAMPLE$ g++ -c main.cpp
feng at feng:~/ODBEXAMPLE$ g++ -c Person-odb.cxx
feng at feng:~/ODBEXAMPLE$ g++ -o main main.o Person-odb.o -lodb-mysql -lodb -lboost_thread -lpthread  -L/usr/local/lib -lboost_system
Person-odb.o:在函数‘odb::boost::date_time::special_value::special_value()’中:
Person-odb.cxx:(.text._ZN3odb5boost9date_time13special_valueC2Ev[_ZN3odb5boost9date_time13special_valueC5Ev]+0x1f):对‘vtable for odb::boost::date_time::special_value’未定义的引用
Person-odb.o:在函数‘odb::mysql::default_value_traits<boost::gregorian::date, (odb::mysql::database_type_id)11>::set_image(st_mysql_time&, bool&, boost::gregorian::date const&)’中:
Person-odb.cxx:(.text._ZN3odb5mysql20default_value_traitsIN5boost9gregorian4dateELNS0_16database_type_idE11EE9set_imageER13st_mysql_timeRbRKS4_[_ZN3odb5mysql20default_value_traitsIN5boost9gregorian4dateELNS0_16database_type_idE11EE9set_imageER13st_mysql_timeRbRKS4_]+0x63):对‘typeinfo for odb::boost::date_time::special_value’未定义的引用
Person-odb.o:在函数‘odb::boost::date_time::special_value::~special_value()’中:
Person-odb.cxx:(.text._ZN3odb5boost9date_time13special_valueD2Ev[_ZN3odb5boost9date_time13special_valueD5Ev]+0x13):对‘vtable for odb::boost::date_time::special_value’未定义的引用
collect2: error: ld returned 1 exit status
---------------------------------------------------------------------


so , l report the bug.
but l want to kown how to maping the boost:::gregorian::date to the mysql database.
there are so unclear write in the ODB Manual .


l am a Software Engineer  from China,and use the odb product in my app, l am very  supportive of your product .
l am very hope to deal with my trouble.
Thanks

   


More information about the odb-users mailing list