Нужна помощь! Подскажите, пожалуйста
Нужно собрать библиотеку dll под линукс.
Код написан на с++ в visual studio. Создаю два файла текстовый и бинарный, пока что данные заполняю сама.
Ниже приведен код:
struct.h
#include <iostream>
struct Station
{
std::string station_name;
std::string rec_dew;
std::string year;
};
struct InfaboutChanell
{
int chanellcount;
int analogChanell;
int discretChanell;
};
struct InfAnalogChanel
{
int id;
std::string chanell_id;
std:: string ph;
std::string ccmb;
std::string UU;
long float a;
double b;
double skew;
double min;
double max;
double Primery;
double Secondary;
std::string SP;
};
struct InfDiscretChanel
{
int DN;
std::string ch_id;
std::string ph;
std::string ccmb;
int y;
};
struct GeneralInf
{
int ifone;
int nrates;
int samp;
int ensamp;
};
makefile.cpp
// Struct.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include "struct.h"
using namespace std;
int main() {
//The first string
struct Station station;
station.station_name="Strathmore 251 kV";
station.rec_dew = "1";
station.year="2001";
ofstream file("fileConfiguration.cfg");
file<<station.station_name<<","<<station.rec_dew<<","<<station.year<<"\n";
//The information about count of channels
struct InfaboutChanell infaboutChanell;
infaboutChanell.chanellcount=14;
const int analogX =6;
infaboutChanell.analogChanell=analogX;
const int discretX=8;
infaboutChanell.discretChanell=discretX;
//проверка на сумму каналов
int sum;
sum = infaboutChanell.analogChanell+infaboutChanell.discretChanell;
if (sum != infaboutChanell.chanellcount)
{
cout << "Please enter correct count of channels: " <<'\n';
}
file<<infaboutChanell.chanellcount<<","<<infaboutChanell.analogChanell<<"A"<<","<<infaboutChanell.discretChanell<<"D"<<"\n";
//The information about analog channels
vector<InfAnalogChanel> s;
InfAnalogChanel a;
InfAnalogChanel b;
InfAnalogChanel c;
InfAnalogChanel d;
InfAnalogChanel e;
InfAnalogChanel f;
a.id=1;
a.chanell_id="ток ф А";
a.ph="";
a.ccmb="";
a.UU="A";
a.a=1.290489E-01;
a.b=0;
a.skew=0;
a.min=-32767;
a.max=32767;
a.Primery=3000.00000000;
a.Secondary=1.00000000;
a.SP="P";
b.id=2;
b.chanell_id="ток В";
b.ph="";
b.ccmb="";
b.UU="A";
b.a=5.139708E-02;
b.b=0;
b.skew=0;
b.min=-32767;
b.max=32767;
b.Primery=3000.00000000;
b.Secondary=1.00000000;
b.SP="P";
c.id=3;
c.chanell_id="ток фaза C";
c.ph="";
c.ccmb="";
c.UU="A";
c.a=7.745668E-02;
c.b=0;
c.skew=0;
c.min=-32767;
c.max=32767;
c.Primery=3000.00000000;
c.Secondary=1.00000000;
c.SP="P";
e.id=4;
e.chanell_id="расчит ноль";
e.ph="";
e.ccmb="";
e.UU="A";
e.a=4.860763E-02;
e.b=0;
e.skew=0;
e.min=-32767;
e.max=32767;
e.Primery=3000.00000000;
e.Secondary=1.00000000;
e.SP="P";
d.id=5;
d.chanell_id="напр В";
d.ph="";
d.ccmb="";
d.UU="V";
d.a=2.611292E+00;
d.b=0;
d.skew=0;
d.min=-32767;
d.max=32767;
d.Primery=60000.00000000;
d.Secondary=57.00000000;
d.SP="P";
f.id=6;
f.chanell_id="напр С";
f.ph="";
f.ccmb="";
f.UU="V";
f.a=2.621923E+00;
f.b=0;
f.skew=0;
f.min=-32767;
f.max=32767;
f.Primery=60000.00000000;
f.Secondary=57.00000000;
f.SP="P";
s.push_back(a);
s.push_back(b);
s.push_back(c);
s.push_back(e);
s.push_back(d);
s.push_back(f);
for(int i=0;i<s.size();++i)
file<<s[i].id<<","<<s[i].chanell_id<<","<<s[i].ph<<","<<s[i].ccmb<<","<<s[i].UU<<","<<s[i].a<<","<<s[i].b<<","<<s[i].skew<<
","<<s[i].min<<","<<s[i].max<<","<<s[i].Primery<<","<<s[i].Secondary<<","<<s[i].SP<<"\n";
//The information about discret chanells
vector<InfDiscretChanel> discret;
InfDiscretChanel first;
InfDiscretChanel sec;
InfDiscretChanel thre;
InfDiscretChanel four;
InfDiscretChanel five;
InfDiscretChanel six;
InfDiscretChanel seven;
InfDiscretChanel eight;
first.DN=1;
first.ch_id = "Раб МТЗ";
first.ph="";
first.ccmb="";
first.y=0;
sec.DN=2;
sec.ch_id = "3_3";
sec.ph="";
sec.ccmb="";
sec.y=0;
thre.DN=3;
thre.ch_id = "8_8";
thre.ph="";
thre.ccmb="";
thre.y=0;
four.DN=4;
four.ch_id = "8_100";
four.ph="";
four.ccmb="";
four.y=0;
five.DN=5;
five.ch_id = "3_8";
five.ph="";
five.ccmb="";
five.y=0;
six.DN=6;
six.ch_id = "3_8";
six.ph="";
six.ccmb="";
six.y=0;
seven.DN=7;
seven.ch_id = "29";
seven.ph="";
seven.ccmb="";
seven.y=0;
eight.DN=8;
eight.ch_id = "41";
eight.ph="";
eight.ccmb="";
eight.y=0;
discret.push_back(first);
discret.push_back(sec);
discret.push_back(thre);
discret.push_back(four);
discret.push_back(five);
discret.push_back(six);
discret.push_back(seven);
discret.push_back(eight);
for(int i=0;i<discret.size();++i)
file<<discret[i].DN<<","<<discret[i].ch_id<<","<<discret[i].ph<<","<<discret[i].ccmb<<","<<discret[i].y<<"\n";
//General information
struct GeneralInf generalinformation;
generalinformation.ifone = 50;
generalinformation.nrates = 1;
generalinformation.samp = 1000;
generalinformation.ensamp = 5107;
file << generalinformation.ifone << "\n" << generalinformation.nrates << "\n" << generalinformation.samp << ","
<< generalinformation.ensamp << "\n";
struct DateTime {
int dd;
int mm;
int yyyy;
int hh;
int min;
long float sec;
string type;
int nfile;
};
vector<DateTime> time;
DateTime samp;
DateTime endsamp;
samp.dd = 24;
samp.mm=10;
samp.yyyy=2017;
samp.hh=10;
samp.min=55;
samp.sec=14.546459;
endsamp.dd = 24;
endsamp.mm=10;
endsamp.yyyy=2017;
endsamp.hh=10;
endsamp.min =55;
endsamp.sec =14.647162;
time.push_back(samp);
time.push_back(endsamp);
for(int i=0;i<time.size();++i)
file<<time[i].dd<<"/"<<time[i].mm<<"/"<<time[i].yyyy<<","<<time[i].hh<<":"<<time[i].min<<":"<<time[i].sec<<"\n";
DateTime type;
type.type = "BINARY";
DateTime nnfile;
nnfile.nfile =1;
file<<type.type<< "\n"<< nnfile.nfile << "\n";
file.close();
// Create Binary file
fstream binary_file("fileConfiguration.dat",ios::out|ios::binary|ios::app);
if(!binary_file)
{
cout << "Cannot open file.\n";
return 1;
}
int i=0;
int n=0;
int timestamp =0;
for (i=0; i<=generalinformation.ensamp; i++){
n = i+1;
binary_file.write((char *) &n, sizeof n);
timestamp = i*1000;
binary_file.write((char *) ×tamp, sizeof timestamp);
// Value of analog channels
short analogValue [analogX];
for(int i=0; i<analogX; i++)
analogValue[i] = rand() % 20000 - 10000;
binary_file.write((char *) &analogValue, sizeof analogValue);
unsigned __int16 m_bytesCount = 0;
m_bytesCount = discretX / 16;
if (discretX % 16){
m_bytesCount++;
}
int ChValue [discretX] = {1, 1, 1, 0, 0, 0, 0, 0};
for(int i = 0; i < discretX; ++i)
{
if(ChValue[i] == 1)
m_bytesCount |= 1 << i;
}
binary_file.write((char *) &m_bytesCount, sizeof m_bytesCount);
}
binary_file.close();
Объясните, пожалуйста, что за чем делать. Не могу найти нормальные, доступные примеры( Очень хочу разобраться