Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

If I compile something and want to send the binary to a friend or post it on the internet, do I need to use some special GCC arguments? Does GCC optimize the binary for my specific CPU and will it run on CPUs that are a bit different or on an other Linux distribution? What else do I need to know?

share|improve this question
1  
Just a remark: Since this is not terribly ubuntu-related, you'd fare better to ask this question on stackoverflow. That would benefit you as well, since SO has more users = more/faster answers. –  con-f-use Jul 27 '11 at 16:07

2 Answers 2

up vote 0 down vote accepted

Generally just need to know the binary format (mac, pc or unix in 32 or 64 bit) and if any special libraries or driver are needed. Most desktop machines run a 64bit pc format. There are some rare formats though. Gcc's default options without optimisation should be fine. There are cross compilers that enable you to compile win binaries on unix.

share|improve this answer
    
s/most desktop machines/most modern laptops and desktops/ –  Lekensteyn Jul 27 '11 at 17:45

It really depends on what is target system architecture.

So if you are trying to run binary on arm or ppc architectures you need to have cross compile toolchains for arm or ppc respectively.

However if you are trying to run it on another computer (which generally use pentium architecture), you can probably get away with 32 bit compatible binary as 32 bit can easily be run on 64 bit machines moreover unless you are using some proprietary technology you would be able to make it cross platform compatible.

Good luck.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.