how to make an executable file by ourselves?

This is a discussion on how to make an executable file by ourselves? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; thank you all, great infos! many thanks! okay , ive got to read sth about the compilers and ill be ...

  1. #16
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    thank you all, great infos! many thanks! okay , ive got to read sth about the compilers and ill be reporting!
    (by the way im using C++(standard you know! tobe able to make it work on on platforms)
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  2. #17
    Complete Beginner
    Join Date
    Feb 2009
    Posts
    312
    Wow. One can hardly expect that statement from a complete beginner.
    From a theoretical viewpoint, a virtual machine is a loop with a switch statement: read the next instruction, decompose it into opcode and operands, call an appropriate function to handle the task. Nothing easier than that, even I could do that. ;-)

    The hard part is optimization, i.e. make it execute faster than compiled code. This involves more advanced techniques such as on-the-fly code profiling, dynamic runtime optimization, hot paths, slim binaries, graph representation, code re-use, matching algorithms, whatever, but these are not specific to virtual machines.

    Greets,
    Philip
    All things begin as source code.
    Source code begins with an empty file.
    -- Tao Te Chip

  3. #18
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    by the way im using C++(standard you know! tobe able to make it work on on platforms)
    A doomed endeavor in the case of a compiler. But using standard C++ makes it easier to port it. Using an external code generator like GCC or LLVM is even better.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #19
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    I didnt get you said! can you be more precise on the meaning! ?
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  5. #20
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    What he means is that you can't write a compiler that's portable. Machine laguage on one platform is different than on another. Executables are different from system to system.

    C++ would make it good for porting, but everything about your target code would be different from machine to machine.

  6. #21
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,246
    Quote Originally Posted by sean View Post
    What he means is that you can't write a compiler that's portable. Machine laguage on one platform is different than on another. Executables are different from system to system.
    But that's exactly what gcc is -- a portable compiler. It uses pluggable modules to translate its optimized intermediate code into the target assembly instructions.

    "Portability" sometimes implies having a set of platform-specific pieces. Nothing can ever be portable in a pure sense, but there's a practical meaning of the word as well.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  7. #22
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    493
    so the only way to do this is to use gcc or LLVM as the compiler! well now how should i merge gcc to my project! and make it work!
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


  8. #23
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    GCC is easy to port, but it's not perfectly portable. As you said, and as I said, that's impossible for a compiler.
    As an aside, GCC's backends are not "pluggable". If you want a compiler that targets a different architecture, you need to compile a complete second copy.
    That's one important difference between LLVM and GCC. LLVM can have multiple backends compiled in, and choose with an option passed to it. It might even be truly run-time pluggable, I'm not sure.
    The other important difference is that merging GCC into a project is just about impossible. What you do is generate code, then call a separate GCC to process that code. With LLVM, you can really integrate it into your executable.

    That said, it's not the only way. It's just the easiest. LLVM has been ported to 9 architectures (x86, x64, IA-64, MIPS, Alpha, ARM, PowerPC, Sparc, CellSPU) plus some pseudo-architectures (it can generate C, C++ or .Net bytecode) - with varying levels of completeness. GCC has been ported to some 30 architectures. Can you even imagine trying to replicate that effort in your own compiler?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21