What is Binary package? How to build them?

56,992

Solution 1

In a strict sense a binary file is one which is not character encoded as human readable text. More colloquially, a "binary" refers to a file that is compiled, executable code, although the file itself may not be executable (referring not so much to permissions as to the capacity to be run alone; some binary code files such as libraries are compiled, but regardless of permissions, they cannot be executed all by themselves). A binary which runs as a standalone executable is an "executable", although not all executable files are binaries (and this is about permissions: executable text files which invoke an interpreter via a shebang such as #!/bin/sh are executables too).

What is a binary package?

A binary package in a linux context is an application package which contains (pre-built) executables, as opposed to source code.

Note that this does not mean a package file is itself an executable. A package file is an archive (sort of like a .zip) which contains other files, and a "binary" package file is one which specifically contains executables (although again, executables are not necessarily truly binaries, and in fact binary packages may be used for compiled libraries which are binary code, but not executables). However, the package must be unpacked in order for you to access these files.

Usually that is taken care of for you by a package management system (e.g. apt/dpkg) which downloads the package and unpacks and installs the binaries inside for you.

What is diference between binary package and deb package?

There isn't -- .deb packages are binary packages, although there are .debs which contain source instead, these usually have -src appended to their name.

I run some direct package which is in "xyz.linux.run" format What are these package?

Those are generally self-extracting binary packages; they work by embedding a binary payload into a shell script. "Self-extracting" means you don't have to invoke another application (such as a package manager) in order to unpack and use them. However, since they do not work with a package manager, resolving their dependencies may be more of a crapshoot and hence some such packages use statically linked executables (they have all necessary libraries built into them) which wastes a bit of memory when they are used.

Solution 2

since the rest of your question was answered by goldilocks, I will weigh in on the first part, how to build things from source.

The really short version is that when you download source files from the internet they will usually have a readme associated with them, which should tell you exactly how to get the program up and running.

But telling you to read the readme doesn't really answer the question, so in a basic sense, you can write a very basic program that is

    #include <stdio.h>

    int main( ) {
        printf("Hello World!");
    }

and type in gcc helloWorld.c and gcc will build that binary and output a program that writes "Hello World!" to the console when run.

Ok, so now you've built a program, however wouldn't it suck to have to type in every single source file that you wanted to compile every time you needed to compile something? That's what makefiles are for. If you run across a program that has a bunch of source files it will usually come with a makefile or some other build automation file (ant, Cmake, or autoconf or something).

To build these types of programs, simply run make <build target> inside the directory. A makefile for my hello world program might include a target called helloworld which just compiles helloWorld.c. I would run this by make helloworld and it would output a binary.

Note that building things from source can take a very long time and large amounts of memory (the Chromium team even recommends a second hard drive to build their source!). Also note that when you are building things from source you will have to deal with dependencies, rather than the package manager doing it for you

Share:
56,992

Related videos on Youtube

Pandya
Author by

Pandya

I use PureOS on old Desktop Computer and Debian GNU/Linux on my Laptop. I want to switch to Guix in future! You may read my Computing History in this meta post :) I recommend visiting Philosophy of GNU Project.

Updated on September 18, 2022

Comments

  • Pandya
    Pandya almost 2 years

    I want to get detail about binary package and run them on linux. I am running Debian base (Ubuntu/Linux mint) Linux os.

    1. How to build binary package from source? And can I directly download binary package for applications (like firefox, etc.) and games (like boswars, etc.) ?
    2. I run some direct package which is in "xyz.linux.run" format What are these package? Are they independent of dependencies? or Is it pre-built binary packages?
    3. How to build them which can be run on linux operating system by directly "xyz.linux.run" on linux.
    4. What is diference between binary package and deb package?
  • Pandya
    Pandya about 10 years
    Excellent Answer!, Should I separate from this Questions: How to build pre-built executable (binary package) from source?
  • goldilocks
    goldilocks about 10 years
    Yeah, that would be a good question all on it's own, if it isn't answered here in some form already.