Thread: Please explain how to package everything needed to compile and run an executable

  1. #1
    Registered User
    Join Date
    Mar 2024
    Posts
    4

    Please explain how to package everything needed to compile and run an executable

    I can't seem to find anywhere online that explains it to me in stupid enough terms for me to accomplish this.

    How do I make sure all the necessary files are there when I run an executable after compilation?

    For this specific program, it's a simple linked list I'm trying to learn to build using a modular strategy. But people have portable programs that are much more complex than the grade school program I've created. So, I'm trying to figure out how to have the necessary files to run the executable like a portable program, but I'm not really sure how that is supposed to be accomplished.

    Is it a command option I'm supposed to be using with the compiler, code that I'm supposed to be adding in the source files telling the program the path and files to access, or is it something that I manually package into the executable like I would a zip file, and then somehow make that executable extract those necessary files to the folder when the executable is run?

    I've been using g++ from the portable versions recommended on the MSYS website to compile a header file, a .cpp definitions file, and a main.cpp file from the Windows command prompt. The executable runs fine IF I have the bin folder listed in PATH, or if I run the executable inside that bin folder.

    But if I remove that folder from my PATH and don't run the executable inside the bin folder, then it gives me an error saying it needs two dll files. How do I provide these two files, as well as any other files needed, to my executable to make it like a portable program? Obviously, not everyone is going to have a folder with these apparently necessary files.
    Last edited by Hb3; 2 Weeks Ago at 06:30 AM.

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    206
    I'll be honest I'm not entirely sure I understand everything you wrote. I do know however that DLL's (which you say are missing sometimes) are linked to at run time (they are not, and are not supposed to be, linked to at compile time). AFAIK the default location for the .exe to look for a DLL is the same folder the .exe is inside of. So if your DLL's aren't there it may well not be able to find and link to them at run time. Can you not just add the DLL's to the same folder as the .exe and zip it up like that?

    Thanks

  3. #3
    Registered User
    Join Date
    Mar 2024
    Posts
    4
    Quote Originally Posted by shrink_tubing View Post
    Can you not just add the DLL's to the same folder as the .exe and zip it up like that?
    Thanks. Is that how this normally works when trying to make a portable thing? I just copy the necessary files and zip them together with the exe? I guess I see that a lot when unzipping portable versions of programs. There's always a number of files that unzip into the folder along with the executable.

    Is there any way to get a list of all the extra files an executable needs?

    What about those programs where all you download is an executable, and then the first time you run it, it places files in the folder the executable is in, or it has some kind of popup like the portable apps site that installs a portable executable into the folder of your choosing. How do those work?

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    206

    Post

    Quote Originally Posted by Hb3 View Post
    What about those programs where all you download is an executable, and then the first time you run it, it places files in the folder the executable is in, or it has some kind of popup like the portable apps site that installs a portable executable into the folder of your choosing. How do those work?
    AFAIK you need to "deploy" your project to make like a little installer for it. That's over my head though maybe check out this link, I don't know if it's what you need?

    Walkthrough: Deploying Your Program (C++) | Microsoft Learn

    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 01-04-2019, 12:00 PM
  2. Replies: 9
    Last Post: 06-21-2009, 01:13 AM
  3. file is needed to run an executable
    By Mona777 in forum C++ Programming
    Replies: 2
    Last Post: 02-25-2009, 04:45 AM
  4. calling an executable from an executable
    By dee in forum C Programming
    Replies: 4
    Last Post: 01-10-2004, 01:32 PM
  5. Command line executable not a KDE executable?
    By FillYourBrain in forum Linux Programming
    Replies: 3
    Last Post: 10-03-2003, 12:01 PM

Tags for this Thread