自己写的小程序 deb打包
Debian 打包学习之C++程序打包
1.编写一个简单程序,包含3个文件,Student.cpp Student.h Mymain.cpp
//-----------------------Studnet.h--------------------//
#ifndef _Student_h
#define _Student_h
#include<string>
using namespace std;
class Student
{
private:
int id;
string name;
int age;
public:
void printAll();
void setId(int id);
void setName(string name);
void setAge(int age);
};
#endif
//-----------------------Studnet.cpp--------------------//
#include "Student.h"
#include <iostream>
#include <string>
using namespace std;
void Student::printAll()
{
cout<<"id="<<id<<endl;
cout<<"name="<<name<<endl;
cout<<"age="<<age<<endl;
}
void Student::setId(int id)
{
this->id=id;
}
void Student::setName(string name)
{
this->name=name;
}
void Student::setAge(int age)
{
this->age=age;
}
//-----------------------Mymain.cpp--------------------//
#include <iostream>
#include "Student.h"
using namespace std;
int main()
{
Student *st=new Student();
st->setId(12);
st->setName("kathy");
st->setAge(24);
st->printAll();
return 0;
}
2. 根据依赖和调用关系,编写makefile文件
Mymain:Mymain.o Student.o
g++ Mymain.o Student.o -o Mymain
Student.o:Student.cpp
g++ -c Student.cpp -o Student.o
Mymain.o:Mymain.cpp
g++ -c Mymain.cpp -o Mymain.o
clean:
rm *.o
-
执行 make 命令,生成可执行文件 Mymain.
-
打包过程
1. 新建一个伪根目录
$ mkdir fakeroot
-
在fakeroot目录下,新建两个目录 DEBIAN 和usr,在usr目录下新建bin目录
$ cd fakeroot
$ mkdir DEBIAN
$ mkdir usr
$ cd usr
$ mkdir bin
-
把生成的可执行程序Mymain拷贝到bin目录下
-
在DEBIAN 目录中新建两个文件 control 和 md5sums
$ vim control
内容如下:
Package: Mymain
Version: 1.0
Architecture: i386
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Florian Ernst <florian@debian.org>
Installed-Size: 96
Depends: libc6 (>= 2.4)
Section: utils
Priority: optional
Homepage: http://mama.indstate.edu/users/ice/tree/
Description: a program written by myself
$ vim md5sums
内容如下:
30c778330f0a57fd83bedee152e12988 usr/bin/Mymain
posted on 2014-07-08 18:22 kathy_dandan 阅读(301) 评论(0) 编辑 收藏 举报