Sisay Zinabu Sisay Zinabu - 6 months ago 18
Linux Question

C++ linux install executable file on deploy environment

Hello every one i need to deploy linux(centos) c++ project with make file or script. By one makefile or script install dependency and project executable binary.
my dependency applications libboost-devel,gcc-g++ and pcre. my excuteble binary file is run_excute

myk myk
Answer

Yip sure - put the below commands into a file. At the top of the file add:

#!/bin/bash

Save the file - lets say you call it install; on the command line type:

chmod +x ./install

Then to build and install your program type:

sudo ./install

Alternatively, if you've got some time on your hands: http://www.rpm.org/max-rpm/ch-rpm-build.html


As an example the basic rpm build process for fedora is:

Step 1: setup your machine to do packaging:

dnf install @development-tools fedora-packager rpmdevtools
rpmdev-setuptree

Step 2: source and Makefile Place these in ~/rpmbuild/SOURCES

Step 3: Create a spec file In ~/rpmbuild/SPECS create file called myname.spec. It should contain something like:

Summary:            My program description
Name:               myname
Version:            0.0.0
Release:            0
License:            GPLv2
Group:              Applications/Databases
Source:             https://xyz.tar.gz
URL:                http://myurl
BuildRequires:      libicu-devel
BuildRequires:      pcre-devel

%description
A couple of lines describing the package

%prep
%setup -q

%build
cd %{myname}/source
make %{?_smp_mflags}

%install
%make_install

%files
%{_bindir}/*

%changelog
* Tue Nov 10 2015 Yours Truly <me@somewhere.com> - 0.0.0-0
- Some change comments

Step 4: create the source and binary rpm

cd ~/rpmbuild/SPECS
rpmbuild -ba myname.spec

Step 5: use the rpm

cd ~/rpmbuild/RPMS/x86_64
rpm -Uvh ./myprogram-version-release.a.whole.lot.of.stuff.rpm
Comments