LINUX.ORG.RU

mysql++ вопрос по с++


0

0

Здравствуйте! В общем небольшой тупняк какой-то. lanlib.cpp

#include "../include/lanlib.h"

taccounts get_accounts_inf(const char* db,const char* server,const char* user, const char* pass,int uid){
		mysqlpp::Connection con(db, server, user, pass);
		stringstream q;
			q<<"select \
			uid,\
			login,\
			pass,\
			balance,\
			descr,\
			name,\
			phone,\
			agrm_num,\
			agrm_date,\
			email,\
			bill_delivery,\
			inn,\
			street,\
			bnum,\
			bknum,\
			apart \
			from accounts where uid=";
			q<<uid;
			mysqlpp::Query query = con.query(q.str());
			taccounts res;
			query.storein(res);
			return res;
}
lanlib.h
#ifndef LAN_LIB___USER_AAA
#define LAN_LIB___USER_AAA
#include <mysql++/mysql++.h>
#include "./stock.h"
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
typedef vector<accounts::accounts> taccounts;
//typedef vector<bills::bills> tbills;
taccounts get_accounts_inf(const char*,const char*,const char*, const char*,int);
//tbills get_bills_inf(const char*,const char*,const char*, const char*,int);
#endif //LAN_LIB___USER_AAA

stock.h

#ifndef STOCK_STURCTURE_AAA
#define STOCK_STURCTURE_AAA
#include <mysql++/mysql++.h>
#include <mysql++/ssqls.h>
namespace accounts{
sql_create_18(accounts,
	1, 18, // The meaning of these values is covered in the user manual
	mysqlpp::sql_int, uid,
	mysqlpp::sql_varchar, login,
	mysqlpp::sql_varchar, pass,
	
	mysqlpp::sql_int, type,
	mysqlpp::sql_double, balance,
	mysqlpp::sql_text, descr,
	
	mysqlpp::sql_varchar, name,
	mysqlpp::sql_varchar, phone,
	mysqlpp::sql_varchar, agrm_num,
	
	mysqlpp::sql_varchar, agrm_date,
	mysqlpp::sql_varchar, email,
	mysqlpp::sql_tinyint, bill_delivery,
	
	mysqlpp::sql_varchar, inn,
	mysqlpp::sql_varchar, city,
	mysqlpp::sql_varchar, street,
	
	mysqlpp::sql_varchar, bnum,
	mysqlpp::sql_varchar, bknum,
	mysqlpp::sql_varchar, apart
	)
}
#endif

pay.cpp

#include "../include/stock.h"
#include "../include/lanlib.h"
#include <mysql++/mysql++.h>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;
int
main(int argc, char *argv[])
{

			
const char* db = "billing", *server = "62.118.130.17", *user = "anton", *pass = "5790";
taccounts res = get_accounts_inf("based","localhost","user","sss",45);
			cout << "We have:" << endl;
		taccounts::iterator it;
        for (it = res.begin(); it != res.end(); ++it) {
            cout << '\t' << it->name;
            cout << " (" << it->uid << ")";
            cout << endl;
        }
return 0;
}
компилирую g++ -I/usr/include/mysql -o./pay ./pay.cpp ./lanlib.cpp -lmysqlpp Получаю ошибки
/tmp/cccwEx2h.o:(.data+0x0): multiple definition of `accounts::accounts::names'
/tmp/ccoGZT4X.o:(.data+0x0): first defined here
/tmp/cccwEx2h.o:(.data+0x48): multiple definition of `accounts::accounts::table_'
/tmp/ccoGZT4X.o:(.data+0x48): first defined here
collect2: выполнение ld завершилось с кодом возврата 1
Чето второй день уже туплю. Помогите пожалуйста.


Ответ на: комментарий от kemm

Спасибо большое! Вопрос решился после прочтения.

jeep
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.