making self contained executables?

This is a discussion on making self contained executables? within the C++ Programming forums, part of the General Programming Boards category; i've tried to find out how to do this before, but my compiler documentation doesn't seem to have any mention ...

  1. #1
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839

    making self contained executables?

    i've tried to find out how to do this before, but my compiler documentation doesn't seem to have any mention of how to do this.

    i use borland c++ builder; i have v6, but could upgrade if necessary.

    what i would like to do is, instead of having to manage the locations of all the library files used by my applications, to compile them into the executable.

    there are lots of apps i use that are totally self-contained executables, so how do i achieve this? what is the correct jargon to google or search the helpfiles with?

    thanks!

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Essentially, you need an executable that is statically linked. I have no direct knowledge of how you do that, but basically it means "don't link to DLL's".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,791
    Quote Originally Posted by m37h0d View Post
    there are lots of apps i use that are totally self-contained executables, so how do i achieve this? what is the correct jargon to google or search the helpfiles with?
    "Most" applications nowadays are not self-contained. They install proper runtime with the installer. Statically linking bloats the size of your program every time. Instead you can install the runtime once and never need it again.
    I prefer the latter.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    Quote Originally Posted by Elysia View Post
    "Most" applications nowadays are not self-contained. They install proper runtime with the installer. Statically linking bloats the size of your program every time. Instead you can install the runtime once and never need it again.
    I prefer the latter.
    thanks, but do you have a link handy or something to help me find out how to actually achieve this?

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,791
    Not for Borland, no.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,249
    Quote Originally Posted by Elysia View Post
    "Most" applications nowadays are not self-contained. They install proper runtime with the installer. Statically linking bloats the size of your program every time. Instead you can install the runtime once and never need it again.
    I prefer the latter.
    Just DLL'izing the runtime doesn't necessarily prevent code bloat. Most applications will install a local copy of the runtime just in case it wasn't there to begin with. (By "runtime" I don't mean the C library -- dynamically linking with that is pretty much a no-brainer.) And installing a runtime for the entire system is a huge no-no, in my book. I hate it when a program wants to touch things in the system directory.

    So the end result is the DLL's get duplicated everywhere anyway. I far prefer this code replication to the nightmare that would result otherwise. Disks are big -- who cares.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,791
    Quote Originally Posted by brewbuck View Post
    Most applications will install a local copy of the runtime just in case it wasn't there to begin with. (By "runtime" I don't mean the C library -- dynamically linking with that is pretty much a no-brainer.)
    That pretty much defeats the purpose of linking dynamically, though. I hate it when programs do that.

    And installing a runtime for the entire system is a huge no-no, in my book. I hate it when a program wants to touch things in the system directory.
    This is where they belong! It's runtime. Therefore it should belong in the system directory so that all programs can access it. That's the point of the directory.

    So the end result is the DLL's get duplicated everywhere anyway. I far prefer this code replication to the nightmare that would result otherwise. Disks are big -- who cares.
    Some people are still stuck on 56k and 26k or worse modems.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    that's all well and good, but i really need this to be as foolproof as possible!

    this application is going to be running on a tool, not someone's personal computer.

    the most important thing to me is that someone can't do something stupid, like move a file, and break it.

  9. #9
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,791
    Install runtime on remote computer.
    Install application on remote computer.
    All works.

    But, you could try switching to an alternate IDE if you really want static. Try Visual Studio for example.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    With risk of derailing this thread further, I'd like to point out that Windows has pretty poor capabilities of coping with a variety of VERSIONS of runtime-DLL's. The Linux model of naming the file with version number all the way down to build-number, and then using symbolic links to get generic versions available to programs that don't care is much better.

    Unfortunately, this means that unless the applications start using:
    MyLibrary4.2.3.11.dll
    instead of
    Mylibrary4.dll

    each application would have to keep it's own copy to ensure that some other DLL of the same name doesn't interfere with it's own one.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,249
    Quote Originally Posted by Elysia View Post
    This is where they belong! It's runtime. Therefore it should belong in the system directory so that all programs can access it. That's the point of the directory.
    Why the heck do I want ALL my programs to break just because one of them installs a buggy library? What if some program relies on some bit of undefined behavior, which changes in the next version of the runtime? Sure, the program is technically buggy by relying on undefined behavior, but try explaining that to the end user who's screaming on the phone that when they installed your program, some other program they use broke.

    IMHO, the only modern function of DLLs is to make upgrading and patching easier, NOT to reduce code replication. As matsp says, the situation is somewhat better on UNIX.

  12. #12
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,791
    I understand what you mean. And I also hate it when programs misuse DLLs like that.
    But... enough of that. The question at hand...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #13
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    so uhh...lots of opinions about it, but does anybody have a clue about how to do it?

  14. #14
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,791
    Ya don't say... I already asked, but... you don't think you can use another IDE? Visual Studio is very good and popular and can do what you want fine.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #15
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    Quote Originally Posted by Elysia View Post
    Ya don't say... I already asked, but... you don't think you can use another IDE? Visual Studio is very good and popular and can do what you want fine.
    yeah, not the first time i've considered doing it, but that's just not a plausible option at this point.

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

Similar Threads

  1. Small executables in VC++ 8
    By Bleech in forum Windows Programming
    Replies: 3
    Last Post: 06-20-2007, 08:28 AM
  2. Making control...
    By Finchie_88 in forum C++ Programming
    Replies: 2
    Last Post: 09-07-2004, 01:42 PM
  3. Replies: 2
    Last Post: 01-13-2003, 12:28 PM
  4. STL + MSVC++ = big executables ?
    By teneniel in forum C++ Programming
    Replies: 6
    Last Post: 11-04-2002, 01:12 PM
  5. Making executables slim.
    By marsface in forum Windows Programming
    Replies: 15
    Last Post: 12-30-2001, 09:08 AM

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