LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Why compile? (https://www.linuxquestions.org/questions/linux-general-1/why-compile-457105/)

matazar42 06-21-2006 09:41 PM

Why compile?
 
Hi everyone, I've been working with Linux for quite a while. I have this general question that I still havn't figured out, that is: why do we have to compile everything from sorce? I mean, in windows no new applications need compiling. They need to be installed. Files put in place regestry entries made etc. But not compiled. I know every distribution of Linux is different and that this means that in order to distribute software to many distributions it is necesarry to compile it for that individual distrobution. But why is this the case? I mean an executable is an executable, right? I can see you needing to configure and install something, but why compile?

Thanks,

-Matt

titanium_geek 06-21-2006 10:10 PM

basically, compilation means that you get software that is best optimized for your system. On the most basic level, all you need to do is
Code:

./configure
make
(as root and optional but recommended)
make install

it's really easy. - and if you want to, you can make sure your machine is working at it's very best.

There are also other ways to package software- look up .rpm and .deb - these are like .exe in a way. Run once and bingo.

titanium_geek

EDIT: This is just a general answer, it doesn't answer your question in full. I think it has something to do with the fact that windows has more limited system requirements and also dll's (dynamic linked libraries) not sure.

Ooh- .exe is for the installer and for the runner, in windows, right? Unix doesn't need to have the .exe or .whatever to make a file executable.

I probably should know the answer here, but I'm just stabbing in the dark, really.

tamoneya 06-21-2006 11:28 PM

titanium geek is right. as for why windows doesnt do it.

1) windows doesnt have to work with the same variety of hardware configurations that linux uses. All windows computers either have a intel or athlon processor for the most part. Linux can have many more options. linux also has different partitioning options than windows. The more options you have the more you gain from optimization by compiling from source.
2)linux is primarily open source and therefore you can compile from source. If you have a non-open source program you cant compile from source because they wont give you the source
3)it is windows and sucks

matazar42 06-22-2006 12:21 AM

So, then it is possible to just distribute the executable for Linux. It's just not perferred because of the increased performance.

Although now that I'm thinking about it, Windows only runs on x86 architecture right? I know you definately need to recompile to change architectures because the processor commands are completely different. Linux can run on a veriety of architectures right? I bet that's the main reason. Even though probably the vast majority run on x86 because that's what's out there.

thanks

daihard 06-22-2006 01:07 AM

Quote:

Originally Posted by matazar42
Although now that I'm thinking about it, Windows only runs on x86 architecture right? I know you definately need to recompile to change architectures because the processor commands are completely different. Linux can run on a veriety of architectures right? I bet that's the main reason. Even though probably the vast majority run on x86 because that's what's out there.

Most Linux programs need compiling because there's no single "version" of Linux available, like Windows 2000/XP. If a particular Windows app works on a Windows XP computer, it is pretty much guaranteed to work on other XP computers because all copies of XP have the exact same versions of the libraries and other OS components. OTOH, "Linux" has many different versions and flavours, which may very well have different versions of glibc, gtk-libs, etc.

That is why generic software for Linux usually comes in source code and build script, and precisely why binary (i.e. precompiled) packages are available for a particular distribution, such as Fedora Core and Mandriva.

cs-cam 06-22-2006 01:09 AM

Just use your package manager to install programs. Most distrobutions have a binary package manager and even most source-based distros have an option to use binary packages.

vikasumit 06-22-2006 01:16 AM

Hi,

Quote:

Originally Posted by tamoneya
1) windows doesnt have to work with the same variety of hardware configurations that linux uses. All windows computers either have a intel or athlon processor for the most part. Linux can have many more options. linux also has different partitioning options than windows. The more options you have the more you gain from optimization by compiling from source.

Windows support many hardware platform, but since windows has different version for different hardware, they have a kind of Pre set enviornment, like Windows CE is for compact device where as general windows is for Desktop etc... If in general you see, you will find that windows and linux mostly used on same platform, i mean have you ever install in on your Mobile phone or your playstation ...Most of us answer it as no they only install Linux on Desktop machine (intel and athlon processors only)

Yes Linux is one package for different hardware, it means you can install Single Linux distro on totally different enviornment not just a desktop machine will be better wording

Quote:

Originally Posted by tamoneya
2)linux is primarily open source and therefore you can compile from source. If you have a non-open source program you cant compile from source because they wont give you the source

That doesn;t mean all linux user have to compile from source ?? does open source says you have to comiple it from source
You only need to compile from source if you want to customize your application as per your requirement... otherwise you can pick its binary from any system and run them (* condition applied explain later)

Quote:

Originally Posted by tamoneya
3)it is windows and sucks

Well I am not sure if you really compile Linux kernal to customize it according to your need... Windows is Non Techincal user Operating system... My Parents can use it like cake, but I am techincal and go software development so it might suite my requirement. Also Windows is commerical product Linux is Every ones product, whosoever want Comiple it without knowing what he is doing ...


Now on main question:-
In general you don't need to compile software for each distro, but since linux is open source, some who hate Windows develop there version of linux (distro) and change some base files location, like in my Red hat I have binary installed in /usr/sbin but in my Debian system it might be in /usr/bin so if a application is compiled using one path, it fails on other system. So we need to recomiple it from source to make it work...

If you make a application that doesn't use any system application like Copy command, or Su or any other, you can use single binary on any distro since they doesn't depend on your system, they are just a executable

Also , some hardware platforms are different in their core working so they need application to use their instruction set which they understand is one of old and main reason one look for open source, not just to blame windows.

and do not compare windows with linux you cannot compare Jet Plans with Fighter Plan they are for different purpose though can be used in same scope...

2damncommon 06-22-2006 01:38 AM

Quote:

Why compile?
Because you can. You decide if you should.

rkelsen 06-22-2006 01:41 AM

Why compile?

Because we can! :D

Edit: Dammit. Beaten to the punch again.

Agrouf 06-22-2006 04:08 AM

Nobody is asking you to compile. You can use binary packages in most distros.
You have to compile when there is no binary package, that is nobody compiled it for you. In Windows, you pay someone to compile and package it for you (you is a group of several thousand people). You have to wait for the package to be ready and you have to pay the bucks and everything else is hidden. the package better suit your need because it is the only one. Hopefully you don't have exotic components.
In linux, you can pick a package already compiled, and you can see the latest version that has not already been packaged and even involve yourself in the development. Everything is open.
In other words, one has to compile in Windows too, but the people who do that do it in secret, whereas in linux they do that openly and you can do it as well. As a result, Windows looks like easier because you don't see everything.

pixellany 06-22-2006 06:25 AM

Quote:

Originally Posted by matazar42
So, then it is possible to just distribute the executable for Linux. It's just not perferred because of the increased performance.

For the vast majority of applications, just using your package manager to install the SW will give you all the performance you need. You would never see the performance increase from compiling your own.

Good package managers (Synaptic in Ubuntu, Pacman in Arch) are far more efficient than the Windows install process.

As others have said, the option of "rolling your own" is there--but you might NEVER need to use it.


All times are GMT -5. The time now is 10:49 AM.