Thread: How do you create exes from your c++ program?

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    18

    How do you create exes from your c++ program?

    How do you create exes from your c++ program? I want to be able to have a user use a gui to design a program and then create a program that they can run anywhere without my program. How can I do this?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You'll need to compile the C++ code with a compiler suitable for the system you want to run your executable on.

    --
    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
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    If you want a user to customize only GUI you may be interested in the .Net programming based on using Windows Presentation Foundation and XAML
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    To be honest, if you really want the user to be able to build an executable from our environment you will be looking more into designing your own language which means you will have to be familiar with machine code. Alternatively you could make something similar to Java or VB whereby the user creates code that is executed by some sort of intermediary interpreter that you've designed. You could call it, C@ (pronounced "cat")

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by master5001 View Post
    To be honest, if you really want the user to be able to build an executable from our environment you will be looking more into designing your own language which means you will have to be familiar with machine code. Alternatively you could make something similar to Java or VB whereby the user creates code that is executed by some sort of intermediary interpreter that you've designed. You could call it, C@ (pronounced "cat")
    Not necessarily - his software could generate C++ code and compile and link it. It depends on how general purpose he wants to make it.

  6. #6
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by medievalelks View Post
    Not necessarily - his software could generate C++ code and compile and link it. It depends on how general purpose he wants to make it.
    Perhaps he could, but he wouldn't be able to call that C@, now would he? Maybe he could call it C& (Cand) or C* (heh... C pointer).

  7. #7
    Registered User
    Join Date
    Sep 2007
    Posts
    18
    My program will generate the c++ code. How would you go about having your program compile and link it?

    (this is not a question about compiling c++ code; im asking about making other programs with your program. what I want to do would be similar to GameMaker (except not nearly as complex))

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You could call the compiler from your application, e.g.
    Code:
    system("cl mycode.cpp");
    Obviously, if you generate multipel source files, etc, you would have to perform a more complex build. You could create a batch-file and then let that perform the compile, for example.

    --
    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.

  9. #9
    Registered User
    Join Date
    Sep 2007
    Posts
    18
    im using windows, how would you link and compile?

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Anubis208 View Post
    im using windows, how would you link and compile?
    "cl" is the Microsoft Visual Studio compiler. Given a single (but complete) source file, it will compile and link the source for you in one step. Of course, if the complete project is not in one file, you either have to give multiple source files to the compile command, or, if you have MANY files to compile, you'd have to compile one or a few files at a time, and link later.

    You should really know how to do that if you are capable of writing an application that generates C++ code. How do you compile that?

    --
    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
    Registered User
    Join Date
    Sep 2007
    Posts
    18
    in order to compile it, I would open it up in some ide (i use Dev-C++) and compile it.
    i am a noob when it comes to the detailed stuff about compiling code. I want to package mingw with my program. I think I can figure it out, but help would be appreciated. I'll tell you if I do figure it out

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Ok, so
    Code:
    system("g++ -o myprog.exe myprog.cpp");
    You do realize that packaging gcc-mingw WITH your package is probably not a great idea. It's likely better that you put a link to where a suitable gcc-mingw can be found on your download page.

    --
    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.

  13. #13
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by matsp View Post
    Ok, so
    Code:
    system("g++ -o myprog.exe myprog.cpp");
    You do realize that packaging gcc-mingw WITH your package is probably not a great idea. It's likely better that you put a link to where a suitable gcc-mingw can be found on your download page.
    Are there licensing issues or are you thinking it will be too large? Or both? :-)

    Personally, I don't like software that asks me to download other software. At the very least, I'd provide an installer that downloads it for them, but I'd prefer to bundle everything they need.

  14. #14
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by medievalelks View Post
    Are there licensing issues or are you thinking it will be too large? Or both? :-)

    Personally, I don't like software that asks me to download other software. At the very least, I'd provide an installer that downloads it for them, but I'd prefer to bundle everything they need.
    Licensing is one thing, size is another. There are plenty of places you can get gcc-mingw, and many may already have a copy installed already - no point in downloading a few extra megs for that. [Or have two packages, one with or one without to solve that particular problem].

    The licensing gets more interesting. If you provide gcc-mingw binaries, you also have to provide the source-code.

    The best option, of course, is to just provide a package that allows the user to use whatever compiler he/she likes [within some reason, of course] - then just tell the user that they will need one of these <some list of compiler> - candidates for that list are recent Visual Studio releases and gcc-mingw.

    There should be little reason (other than "how do I compile" that changes between compilers as long as the generated code is reasonably standards compliant, so why force the user onto a particular compiler.

    --
    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.

  15. #15
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by matsp View Post

    There should be little reason (other than "how do I compile" that changes between compilers as long as the generated code is reasonably standards compliant, so why force the user onto a particular compiler.
    It depends on the target market. The users may not be programmers at all. They're just pushing buttons, dragging and dropping, and kicking screensavers (or whatever) out the back.

    It also depends on what the developer tested with. Generated code that compiles with MinGW may not with VC++, or vice versa.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  3. How to create a file association program?
    By eShain in forum Windows Programming
    Replies: 1
    Last Post: 03-06-2006, 12:15 PM
  4. Trying to create a payroll calculation program
    By nadeni0119 in forum C++ Programming
    Replies: 1
    Last Post: 04-01-2003, 04:14 PM
  5. program won't create status bar
    By Unregistered in forum Windows Programming
    Replies: 7
    Last Post: 08-30-2001, 04:00 PM