Thread: How does ebook to exe application compile to self-contained executable

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    58

    How does ebook to exe application compile to self-contained executable

    I am trying to understand how various ebook applications compile their output into a self-contained executable file with no dependencies when you run the exe. How can it be done? Do they use real embedded compiler?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> various ebook applications

    "ebook" is a broad term. What particular application(s) are you referring to?

    >> self-contained executable file with no dependencies when you run the exe. How can it be done? Do they use real embedded compiler?

    Define "no dependancies". As in "running depends.exe shows no dependancies"?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Compile a program (this will be your generated app), and make it read one of it's resources for instructions on what to do. Put this program within your parent program's resources.
    Now, to 'generate' your application, extract the resource to an exe file, and update the extraction's resources via UpdateResource(), giving the generated application it's uniqueness.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> Compile a program (this will be your generated app), and make it read one of it's resources for instructions on what to do.

    Oh that makes sense. I thought he was talking about "dll dependencies", but he probably was referring to the actual book data.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    58
    Yarin
    does it creates one single exe file ?
    with no configurations or data files that this exe depends on it ?
    can you please give me links for examples?
    Thanks allot

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> does it creates one single exe file ?

    Yes, using Windows resources, you can store just about anything in the executable. Most compilers come with a resource compiler.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  7. #7
    Registered User
    Join Date
    Mar 2008
    Posts
    58
    does it load it on run time ?
    one thing i dont understand here ..
    lts say i build the exe in my compiler then i direct it to load resource file .
    now i like to be able to give the users to make there own content and then
    my application ( that dont contains compiler ) will save it as single exe.
    who does it work ?

  8. #8
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    >> who does it work ?

    I already told you.

    When the user wants to "create" their own app. Just extract the one you have in the program's resources. Then make the same program update the resources of the extraction right away.
    Inside your 'custom' program, you'll have code that does different things depending on the resources that got updated.

    In reality, each "created" app would be the same thing, (with different resources) but the end user wouldn't notice. This way, no embedded compiler, or anything else super-complicated, would be required.

    Very often, programming is all about trickery.

  9. #9
    Registered User
    Join Date
    Mar 2008
    Posts
    58
    Thanks for the fast reply
    can you please point me to some tutorials or links
    Thanks

  10. #10
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Assuming that you have, at this point, a resource compiler handy and have already added a resource to your application, you just need to call FindResource and LoadResource to retrieve it. To do that, you're going to need a few pieces of information:
    1) Your applications HMODULE value. You can use GetModuleHandle(NULL), or simply your application's HINSTANCE to fetch this value.
    2) The name or ID of the resource. If it's an ID, you'll need to use the MAKEINTRESOURCE macro to "convince" the compiler that it's a string (it's just a Windows kludge, don't worry about the details, for now).
    3) The type of resource (eg: RT_ACCELERATOR, RT_ANICURSOR, RT_ANIICON, RT_BITMAP, RT_CURSOR, RT_DIALOG, RT_FONT, RT_FONTDIR, RT_GROUP_CURSOR, RT_GROUP_ICON, RT_ICON, RT_MENU, RT_MESSAGETABLE, RT_RCDATA, RT_STRING, or RT_VERSION)
    4) The value returned by FindResource.

    Now just pass #1, #2, and #3 to FindResource, and then #1 and #4 to LoadResource. That's basically it.

    EDIT:
    It looks like you can simply use the value NULL for #1. Either way should work, though.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Does C# compile to an exe?
    By thetinman in forum C# Programming
    Replies: 7
    Last Post: 11-21-2008, 11:17 AM
  2. Replies: 5
    Last Post: 07-13-2008, 08:16 PM
  3. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 09:19 AM
  4. No compile time errors, exe crashes.
    By RealityFusion in forum C++ Programming
    Replies: 13
    Last Post: 09-06-2005, 12:34 PM
  5. Linking problems trying to compile QT application
    By Maragato in forum C++ Programming
    Replies: 1
    Last Post: 08-19-2005, 09:08 PM