Code to compile???

Hi,
I need my program in C to compile a .c file. I remember that there is a call of system to do that. Something like system("compile the file",file.c,file.exe)
I dont remember how to do that. please can u help me :D

thanks


Answer this question

Code to compile???

  • cnSoftware

    First, try your full cl.exe command from a cmd prompt. If that works, then attempt to do it via code. It's far easier to figure out what's wrong if you do it that way.

  • LornaJoy

    You can just execute the compiler from straight ahead assuming that you have the compiler binaries in the path. system("cl.exe a.c") should compile a.c.

    cl.exe is the compiler driver. You can test that by going to the VS command prompt and executing cl.exe yourself.

    Hope this helps!

    Thanks,
    Ayman Shoukry
    VC++ Team


  • Dale Shetler

    Use the full path then. Or set the PATH environment variable properly.

    severo1980 wrote:
    It said that cl.exe is not recognized as a command, and cl.exe is in the bin folder. :(



  • gtmulg

    i ve wrote the following line:

    system("cl.exe file.c"); nothing...

    then system("c:/Program Files/......../VS/../Bin/cl.exe file.c"); nothing...

    then, i tried so many things, until windows told me that he couldn't find mspdb71.dll
    Whats that Sry, but are years that i dont use C. I cant remember this mf system :@

    about this: how can I, in the case cl.exe works, to put the file name (mean file.exe) Or it just get the .c name

    Thanks!!

  • adamcalderon

    severo1980 wrote:

    then system("c:/Program Files/......../VS/../Bin/cl.exe file.c"); nothing...

    It looks like you'll have to SET the environment variables by running vsvars32.bat/vcvars32.bat. But as you know (or will know) you can't just run SET commands and expect your own environment to have changed (SET will only affect the environment of the child process).

    WORKAROUND: create a temporary batch file (call it something like compiletmp.bat) with the following contents:

  • Juan Foegen

    It said that cl.exe is not recognized as a command, and cl.exe is in the bin folder. :(

  • Code to compile???