For some reason, with the command "g ++ -c code.cpp -o r.exe" the application does not work at the output. Yes, and if the file itself is opened with a notepad, then there, apparently, is not what it really should be. + The file size is clearly not what the application should have.

If you use this command "g ++ -s code.cpp", then the output will be a working full executable file.

The question is, what can the command need to add (which is -c -o) and then it will work ?. Maybe there still need to link and something else. The second option is working, but is it correct? I read the documentation, but I didn’t taste it yet.

How correct is it to be? Some whole makefiles write more. Maybe I should? =) Many people propose to use IDE, but I already have the opposite - I want to get off the IDE =)

    1 answer 1

    Read the documentation

    Check?

    with the command "g ++ -c code.cpp -o r.exe" the application does not work at the output

    And should not:

    do not link

    Farther,

    If you use this command "g ++ -S code.cpp", then the output will be a working full executable file.

    Do not you say :)

    -S Stop after the stage of compilation proper; do not assemble. It is a code for each non-assembler input file specified.

    Well, there is no way to get a "working executable file" here.

    The question is, what can the command need to add (which is -c -o) and then it will work?

    The question is different. These keys do exactly what they should do, but you do not seem to need this. So what is needed? Just build the executable file from source? Voila (as written in the documentation):

    g++ code.cpp -o r.exe 
    • mingw32-g ++ -s ura.cpp -Wall -ansi The output was a file a.exe; I do not know what kind of magic. - Taranga
    • g ++ code.cpp -o r.exe - Yes. Got it. Thank. I do not know why I tried to add -c =) - Taranga
    • @Taranga, do not be misleading. In the question the key is -S , not -s , these are completely different keys. The -s causes the linker to use a static linker, which, apparently, in your case rolls. Read the documentation, it has everything. - PinkTux
    • =) Good. Wrong. Excuse me. - Taranga