Results 1 to 5 of 5

Thread: .o .dll and .exe

  1. #1
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default .o .dll and .exe

    Hello,

    I'm trying to figure out what a .o, .exe and .dll files are.

    Lets assume I have a very basic program that just has one .cpp file without any includes, which then gets compiled into a .o by the compiler. What's the difference between this example .o file and an .exe file?

    Lets assume I have a basic .dll which just has one .cpp and no extra includes, what's the difference between such an example .o and a .dll?

    I suppose my question can be summarised to what does the linker do exactly that the compiler does not in such a simple case?

    In more complex cases where various includes are involved, I can only imagine it simply copies and pastes the various files into one big one.

    At the end of the day, a .dll a .exe and a .o file are machine code no?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: .o .dll and .exe

    The .o is an Object File. It contains all the symbols from a single translation unit (.cpp file).
    It does not contain anything else.

    If your program has just one cpp file you can usually skip the .o creation an go directly to the program or library output (doing compiling and linking in one compiler invocation).

    A DLL is a dyamic library, something that the system's runtime linker can load when required and then perform symbol lookup to find the symbols needed by the application.
    An EXE is a Windows executable format, a program that can be started by the operating system.

    Both DLL and EXE will contain additional code, generated by the compiler/linker, that provides the entry points for the operating system.

    Depending on settings and in-code markers the linker will very likely also have removed unneeded symbols at this stage.
    E.g. if any .o contains functions that are not needed anywhere in the program, they might have be removed and no longer be part of the DLL or EXE.

    Cheers,
    _

  3. #3
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: .o .dll and .exe

    I think I understand thanks.

    Another question however:

    I opened a .o file to see what is inside and found a bunch of gibberish, shouldn't this be machine code i.e. a bunch of 1 and 0? Is it ASCII? Is it something to do with hexadecimal?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: .o .dll and .exe

    Everything on your computer is a bunch of 1s and 0s. Any program loading data interprets these binary codes depending on what it assumes the file contains.

    If you open something in a text editor it will interpret the bytes as text, if you open it in an image viewer it will interpert the bytes as image data.
    If you open something in a hex editor, it will display the value of each byte as hexadecimal values, i.e. two characters per byte

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    Atomic_Sheep (22nd April 2014)

  6. #5
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: .o .dll and .exe

    Ah I think I see, many thanks!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.